Skip to content

Commit

Permalink
chore: upload acir artifacts as a github artifact (#3288)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Oct 26, 2023
1 parent a5c353d commit 4894162
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/auto-pr-rebuild-script.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
name: Rebuild ACIR artifacts

on:
pull_request:
push:
branches:
- master

jobs:
check-artifacts-requested:
name: Check if artifacts should be published
runs-on: ubuntu-22.04
outputs:
publish: ${{ steps.check.outputs.publish }}

steps:
- name: Check if artifacts should be published
id: check
run: |
if [ ${{ github.ref_name }} == "master" ]; then
# Always publish on master
echo "publish=true" >> "$GITHUB_OUTPUT"
else
# Only publish on PRs if label is set
HAS_ARTIFACT_LABEL=$(gh pr view $PR --repo $REPO_URL --json labels | jq '.labels | any(.name == "publish-acir")')
echo "publish=$HAS_ARTIFACT_LABEL" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
REPO_URL: ${{ github.repositoryUrl }}

build-nargo:
name: Build nargo binary
runs-on: ubuntu-22.04
needs: [check-artifacts-requested]
if: ${{ needs.check-artifacts-requested.outputs.publish == true }}
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
Expand Down Expand Up @@ -42,6 +69,7 @@ jobs:
retention-days: 3

auto-pr-rebuild-script:
name: Rebuild ACIR artifacts
needs: [build-nargo]
runs-on: ubuntu-latest

Expand Down Expand Up @@ -71,10 +99,19 @@ jobs:
chmod +x ./rebuild.sh
./rebuild.sh
- name: Upload ACIR artifacts
uses: actions/upload-artifact@v3
with:
name: acir-artifacts
path: ./tooling/nargo_cli/tests/acir_artifacts
retention-days: 10

- name: Check for changes in acir_artifacts directory
id: check_changes
if: ${{ github.ref_name }} == "master"
run: |
git diff --quiet tooling/nargo_cli/tests/acir_artifacts/ || echo "::set-output name=changes::true"
- name: Create or Update PR
if: steps.check_changes.outputs.changes == 'true'
Expand Down
7 changes: 4 additions & 3 deletions tooling/nargo_cli/tests/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ for dir in $base_path/*; do
# Delete the JSON file after extracting bytecode field
rm ./target/${dir_name}.json

# Delete the target directory in acir_artifacts if it exists
# Clear the target directory in acir_artifacts
if [ -d "$current_dir/acir_artifacts/$dir_name/target" ]; then
rm -r "$current_dir/acir_artifacts/$dir_name/target"
fi
mkdir $current_dir/acir_artifacts/$dir_name/target

# Move the target directory to the corresponding directory in acir_artifacts
mv ./target/ $current_dir/acir_artifacts/$dir_name/
# Move the artifacts from the target directory to the corresponding directory in acir_artifacts
mv ./target/*.gz $current_dir/acir_artifacts/$dir_name/target/

cd $base_path
fi
Expand Down

0 comments on commit 4894162

Please sign in to comment.