Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦀 Migrated project to Rust 🦀 #2

Merged
merged 32 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bb5a6ce
migrated codebase to run with rust
Bullrich May 23, 2024
c5fad41
updated gitignore
Bullrich May 23, 2024
73a3fb8
updated name of exported variable
Bullrich May 23, 2024
fe8eb3a
removed unused imports
Bullrich May 23, 2024
7ebda73
Updated readme
Bullrich May 23, 2024
8b97be7
removed unused files
Bullrich May 23, 2024
9570d99
updated docker image
Bullrich May 23, 2024
9a23b0b
added step to test CI
Bullrich May 23, 2024
5e4a2b5
moved image to run in dockerfile
Bullrich May 23, 2024
41b5011
test action on itself
Bullrich May 23, 2024
780c024
removed unused dependency
Bullrich May 23, 2024
cc6ae14
updated docker version
Bullrich May 23, 2024
0b037aa
unified tests into matrix
Bullrich May 23, 2024
70d0e16
fixed version in test action
Bullrich May 23, 2024
91a220b
fixed docker image not compiling
Bullrich May 23, 2024
789a6d5
removed push from test action
Bullrich May 23, 2024
d9d0b90
removed unnecessary step in dockerimage
Bullrich May 23, 2024
87addfb
updated to use context library
Bullrich May 24, 2024
e9276b0
updated library to version 0.0.3
Bullrich May 27, 2024
ffe7d07
updated `actions-github` with `set_output` method
Bullrich May 27, 2024
9f55e47
cleaned code issues
Bullrich May 27, 2024
1bdc9c8
updated lib to 0.0.5
Bullrich May 27, 2024
d319316
updated all tests
Bullrich May 27, 2024
fc0de69
added cargo.lock
Bullrich May 27, 2024
c4fc61e
added actions/cache to github action
Bullrich May 27, 2024
af61e5f
applied code changes
Bullrich May 28, 2024
a3bdb89
removed clone from team
Bullrich May 28, 2024
e8bdcec
updated CI to use crate instead of package
Bullrich May 28, 2024
a8ac16f
updated CI to upload version
Bullrich May 28, 2024
df95400
restored old action version
Bullrich May 28, 2024
e9a1149
updated version to match cargo.toml
Bullrich May 28, 2024
f28f80e
updated test-action to point to main
Bullrich May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 48 additions & 79 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,71 @@ on:

env:
IMAGE_NAME: action
REGISTRY: ghcr.io

jobs:
test-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
- name: Check that the image builds
run: docker build . --file Dockerfile

test-versions:
compare-versions:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.verification.outputs.VERSION }}
exists: ${{ steps.checkTag.outputs.exists }}
steps:
- uses: actions/checkout@v3.3.0
- name: Extract package.json version
- uses: actions/checkout@v4
- run: pip install toml-cli
- name: Extract crate version
id: package_version
run: echo "VERSION=$(jq '.version' -r package.json)" >> $GITHUB_OUTPUT
- name: Extract action.yml version
uses: mikefarah/yq@master
id: action_image
with:
cmd: yq '.runs.image' 'action.yml'
- name: Parse action.yml version
id: action_version
run: |
echo "IMAGE_VERSION=$(echo $IMAGE_URL | cut -d: -f3)" >> $GITHUB_OUTPUT
env:
IMAGE_URL: ${{ steps.action_image.outputs.result }}
run: echo "VERSION=$(toml get --toml-path Cargo.toml package.version)" >> $GITHUB_OUTPUT
# Compare that the versions contain the same name
- name: Compare versions
run: |
echo "Verifying that $IMAGE_VERSION from action.yml is the same as $PACKAGE_VERSION from package.json"
[[ $IMAGE_VERSION == $PACKAGE_VERSION ]]
env:
IMAGE_VERSION: ${{ steps.action_version.outputs.IMAGE_VERSION }}
PACKAGE_VERSION: ${{ steps.package_version.outputs.VERSION }}
id: verification
uses: Bullrich/compare-version-on-action@main
with:
version: ${{ steps.package_version.outputs.VERSION }}
# Verifies if there is a tag with that version number
- uses: mukunku/tag-exists-action@v1.6.0
if: steps.verification.outputs.VERSION
id: checkTag
with:
tag: v${{ steps.package_version.outputs.VERSION }}

tag:
if: github.event_name == 'push'
needs: [test-image, test-versions]
publish:
if: github.event_name == 'push' && needs.compare-versions.outputs.exists == 'false'
needs: [test-image, compare-versions]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tagcreated: ${{ steps.autotag.outputs.tagcreated }}
tagname: ${{ steps.autotag.outputs.tagname }}
packages: write
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
- name: Tag version and create release
run: gh release create $VERSION --generate-notes
env:
VERSION: v${{ needs.compare-versions.outputs.version }}
GH_TOKEN: ${{ github.token }}
- name: Log in to the Container registry
uses: docker/login-action@v3.1.0
with:
fetch-depth: 0
- uses: butlerlogic/action-autotag@stable
id: autotag
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
head_branch: master
tag_prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Changelog
uses: Bullrich/generate-release-changelog@2.0.2
id: Changelog
env:
REPO: ${{ github.repository }}
- name: Create Release
if: steps.autotag.outputs.tagname != ''
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: ${{ needs.compare-versions.outputs.version }}
- uses: actions/checkout@v4
- name: Build and push Docker image
uses: docker/build-push-action@v5.3.0
with:
tag_name: ${{ steps.autotag.outputs.tagname }}
release_name: Release ${{ steps.autotag.outputs.tagname }}
body: |
${{ steps.Changelog.outputs.changelog }}
publish:
runs-on: ubuntu-latest
permissions:
packages: write
needs: [tag]
if: needs.tag.outputs.tagname != ''
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
env:
TAG: ${{ needs.tag.outputs.tagname }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 30 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Find team members

on:
pull_request:
push:
branches:
- main

jobs:
get-team:
runs-on: ubuntu-latest
steps:
- name: Fetch team data
# We add the id to access to this step outputs
id: teams
uses: paritytech/list-team-members@main
with:
ACCESS_TOKEN: ${{ secrets.READ_ORG_PAT }}
team: opstooling
# optional, in case that it searches on a different organization
organization: paritytech
# example showing how to use the content
- name: Show data
run: |
echo "The users are $USERNAMES"
echo "Data: $DATA"
env:
USERNAMES: ${{ steps.teams.outputs.usernames }}"
# a json object
DATA: ${{ steps.teams.outputs.data }}"
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
pull_request:
push:
branches:
- main

name: Continuous integration

jobs:
test:
name: "Test"
strategy:
fail-fast: true
matrix:
cmd:
- check
- fmt --all -- --check
- clippy -- -D warnings
- doc
- test
- build --release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo ${{ matrix.cmd }}
conclude:
runs-on: ubuntu-latest
name: All tests passed
needs: [test]
steps:
- run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY
102 changes: 8 additions & 94 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,18 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# DynamoDB Local files
.dynamodb/
# These are backup files generated by rustfmt
**/*.rs.bk

# TernJS port file
.tern-port
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
Loading