From 5d73d3ec05072765296801867eb73b69df69a1b9 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:37:02 +0100 Subject: [PATCH] chore: upload acir artifacts as a github artifact (#3288) --- .github/workflows/auto-pr-rebuild-script.yml | 37 ++++++++++++++++++++ tooling/nargo_cli/tests/rebuild.sh | 7 ++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-pr-rebuild-script.yml b/.github/workflows/auto-pr-rebuild-script.yml index 5e46e46ed4c..7b551b0aece 100644 --- a/.github/workflows/auto-pr-rebuild-script.yml +++ b/.github/workflows/auto-pr-rebuild-script.yml @@ -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] @@ -42,6 +69,7 @@ jobs: retention-days: 3 auto-pr-rebuild-script: + name: Rebuild ACIR artifacts needs: [build-nargo] runs-on: ubuntu-latest @@ -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' diff --git a/tooling/nargo_cli/tests/rebuild.sh b/tooling/nargo_cli/tests/rebuild.sh index 9776745a1f7..d89402fb1cf 100755 --- a/tooling/nargo_cli/tests/rebuild.sh +++ b/tooling/nargo_cli/tests/rebuild.sh @@ -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