From 6060ccd56089d867690dbe49aa5c9dccd879f61b Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Sat, 22 Feb 2025 11:28:17 +0100 Subject: [PATCH] fixup: Cleanup action usage --- .github/actions/install-nix/action.yml | 16 ++++++++++ .../run-monitored-tmpnet-cmd/action.yml | 11 ++++--- .github/workflows/ci.yml | 30 ++++++++----------- 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 .github/actions/install-nix/action.yml diff --git a/.github/actions/install-nix/action.yml b/.github/actions/install-nix/action.yml new file mode 100644 index 000000000000..d60043b078b8 --- /dev/null +++ b/.github/actions/install-nix/action.yml @@ -0,0 +1,16 @@ +name: 'Install nix' +description: 'Install nix and populate the store for the repo flake' + +inputs: + github_token: + description: "github token to authenticate with to avoid being rate-limited" + default: ${{ github.token }} + required: false + +runs: + using: composite + steps: + - uses: cachix/install-nix-action@v30 + with: + github_access_token: ${{ inputs.github_token }} + - run: nix develop --command echo "dependencies installed" diff --git a/.github/actions/run-monitored-tmpnet-cmd/action.yml b/.github/actions/run-monitored-tmpnet-cmd/action.yml index a1e85a2836bf..1534caa18ca4 100644 --- a/.github/actions/run-monitored-tmpnet-cmd/action.yml +++ b/.github/actions/run-monitored-tmpnet-cmd/action.yml @@ -7,8 +7,11 @@ inputs: required: true filter_by_owner: default: '' - artifact_name: - default: 'tmpnet-data' + artifact_prefix: + default: '' + # TODO(marun) Supply these to the command + env: + default: {} prometheus_username: required: true prometheus_password: @@ -65,7 +68,7 @@ runs: FILTER_BY_OWNER: ${{ inputs.filter_by_owner }} - name: Run command shell: bash - run: ${{ inputs.run }} + run: nix develop --impure --command bash -x ${{ inputs.run }} env: TMPNET_DELAY_NETWORK_SHUTDOWN: true # Ensure shutdown waits for a final metrics scrape GH_REPO: ${{ inputs.repository_owner }}/${{ inputs.repository_name }} @@ -78,4 +81,4 @@ runs: uses: ./.github/actions/upload-tmpnet-artifact if: always() with: - name: ${{ inputs.artifact_name }} + name: ${{ inputs.artifact_prefix }}-tmpnet-data diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fd9a786a44a..892d86039b8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,20 +51,18 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-go-for-project - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - # TODO(marun) Maybe figure out how to use `nix build` somehow i.e. make the default shell double as the default package - - run: nix develop --command echo "dependencies installed" + - uses: ./.github/actions/install-nix - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r - name: Run e2e tests uses: ./.github/actions/run-monitored-tmpnet-cmd with: - run: E2E_SERIAL=1 ./scripts/tests.e2e.sh - artifact_name: e2e-tmpnet-data + run: ./scripts/tests.e2e.sh + artifact_prefix: e2e filter_by_owner: avalanchego-e2e + env: + E2E_SERIAL: 1 prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }} @@ -74,18 +72,17 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-go-for-project - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix develop --command echo "dependencies installed" + - uses: ./.github/actions/install-nix - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r - name: Run e2e tests with existing network uses: ./.github/actions/run-monitored-tmpnet-cmd with: - run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh - artifact_name: e2e-existing-network-tmpnet-data + run: ./scripts/tests.e2e.existing.sh + artifact_prefix: e2e-existing-network + env: + E2E_SERIAL: 1 prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }} @@ -95,10 +92,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-go-for-project - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix develop --command echo "dependencies installed" + - uses: ./.github/actions/install-nix - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh @@ -106,7 +100,7 @@ jobs: uses: ./.github/actions/run-monitored-tmpnet-cmd with: run: ./scripts/tests.upgrade.sh - artifact_name: upgrade-tmpnet-data + artifact_prefix: upgrade prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }}