From 760e223ba3adf2ac7bfee2d131050ed7c4a202d1 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Tue, 5 Mar 2024 14:11:14 -0500 Subject: [PATCH 1/7] feature(ci): Run docker build on all pushes --- .github/workflows/release-ghcr.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index bfc20cd68..3a78b77a9 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -4,10 +4,12 @@ on: release: types: - published - push: - tags: - - '**' + push: {} + pull_request: {} workflow_dispatch: {} + schedule: + # Everyday at 4:00 AM UTC + - cron: "0 4 * * *" env: REGISTRY: ghcr.io @@ -52,6 +54,7 @@ jobs: echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_ENV" - name: Upload ${{ github.actor }}/cardano-db-sync + if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} run: | # Download the image from the nix binary cachhe nix build --builders "" --max-jobs 0 .#cardano-db-sync-docker @@ -67,6 +70,7 @@ jobs: docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:latest - name: Upload ${{ github.actor }}/cardano-smash-server + if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} run: | # Download the image from the nix binary cachhe nix build --builders "" --max-jobs 0 .#cardano-smash-server-docker From c5133af20d262eed219d8ef2ad590019cd9d7362 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Tue, 5 Mar 2024 14:37:58 -0500 Subject: [PATCH 2/7] feature(ci): Add wait-for-hydra --- .github/workflows/release-ghcr.yml | 37 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index 3a78b77a9..8a596db3a 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -13,10 +13,11 @@ on: env: REGISTRY: ghcr.io + GH_TOKEN: ${{ github.token }} jobs: build: - name: "Upload to ghcr.io" + name: "Build image" runs-on: ubuntu-latest steps: - name: Install Nix with good defaults @@ -53,34 +54,48 @@ jobs: echo "REPO_OWNER=${REPO_OWNER}" >> "$GITHUB_ENV" echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_ENV" + - name: Wait for Hydra + uses: input-output-hk/actions/wait-for-hydra@latest + with: + check: ci/hydra-build:x86_64-linux.required + + - name: Load images + run: | + # Download the images from the nix binary cachhe + nix build \ + --builders "" \ + --max-jobs 0 \ + --out-link result-cardano-db-sync \ + .#cardano-db-sync-docker + + nix build \ + --builders "" \ + --max-jobs 0 \ + --out-link result-cardano-smash-server + .#cardano-smash-server-docker + - name: Upload ${{ github.actor }}/cardano-db-sync if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} run: | - # Download the image from the nix binary cachhe - nix build --builders "" --max-jobs 0 .#cardano-db-sync-docker - # Push the image skopeo copy \ - docker-archive:./result \ + docker-archive:./result-cardano-db-sync \ docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:$IMAGE_TAG # Also tag it as latest skopeo copy \ - docker-archive:./result \ + docker-archive:./result-cardano-db-sync \ docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:latest - name: Upload ${{ github.actor }}/cardano-smash-server if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} run: | - # Download the image from the nix binary cachhe - nix build --builders "" --max-jobs 0 .#cardano-smash-server-docker - # Push the image skopeo copy \ - docker-archive:./result \ + docker-archive:./result-cardano-smash-server \ docker://ghcr.io/${REPO_OWNER}/cardano-smash-server:$IMAGE_TAG # Also tag it as latest skopeo copy \ - docker-archive:./result \ + docker-archive:./result-cardano-smash-server \ docker://ghcr.io/${REPO_OWNER}/cardano-smash-server:latest From e9ee97d27c730378677ecb576e17a3652831f1a7 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Tue, 21 May 2024 14:50:09 -0400 Subject: [PATCH 3/7] build: Do not run release-ghcr on `pull_request` The `pull_request` trigger tries to merge the base branch, and Hydra uses the commit tip, so nix will usually not resolve the correct artifact. --- .github/workflows/release-ghcr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index 8a596db3a..a0a6db9a7 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -5,7 +5,6 @@ on: types: - published push: {} - pull_request: {} workflow_dispatch: {} schedule: # Everyday at 4:00 AM UTC From 0cdad5ac8d2b89946f6c353524711b2877575cc0 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Thu, 23 May 2024 16:13:00 -0400 Subject: [PATCH 4/7] build: Fix typo --- .github/workflows/release-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index a0a6db9a7..1f6ae00ac 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -70,7 +70,7 @@ jobs: nix build \ --builders "" \ --max-jobs 0 \ - --out-link result-cardano-smash-server + --out-link result-cardano-smash-server \ .#cardano-smash-server-docker - name: Upload ${{ github.actor }}/cardano-db-sync From 58ec57e8bd2b4b015f9246bee9a295b6e1175e9e Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Thu, 23 May 2024 16:24:16 -0400 Subject: [PATCH 5/7] REMOVEME: Add some debug statements --- .github/workflows/release-ghcr.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index 1f6ae00ac..d68dcd697 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -73,6 +73,10 @@ jobs: --out-link result-cardano-smash-server \ .#cardano-smash-server-docker + # REMOVEME: debugging + echo "ref_type=${{ github.ref_type }}" + echo "event_name=${{ github.event_name }}" + - name: Upload ${{ github.actor }}/cardano-db-sync if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} run: | From 20d47fa40e873f0167093699929f3ddcded244c4 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Thu, 23 May 2024 16:35:42 -0400 Subject: [PATCH 6/7] build: fix more typos --- .github/workflows/release-ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index d68dcd697..7cdc574fd 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -78,7 +78,7 @@ jobs: echo "event_name=${{ github.event_name }}" - name: Upload ${{ github.actor }}/cardano-db-sync - if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} + if: ${{ github.ref_type == 'tag' || github.event_name == 'release' }} run: | # Push the image skopeo copy \ @@ -91,7 +91,7 @@ jobs: docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:latest - name: Upload ${{ github.actor }}/cardano-smash-server - if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }} + if: ${{ github.ref_type == 'tag' || github.event_name == 'release' }} run: | # Push the image skopeo copy \ From e51cced560e06402fd9f6166b57d37e1ba2ca63c Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Thu, 23 May 2024 16:44:53 -0400 Subject: [PATCH 7/7] build(nix): Add docker builds to required aggregate --- flake.nix | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index b09d3b87e..1920b8cb8 100644 --- a/flake.nix +++ b/flake.nix @@ -333,23 +333,26 @@ nonRequiredMacOSPaths else []; + extraCiJobs = + lib.optionalAttrs (system == "x86_64-linux") { + inherit + cardano-db-sync-linux + cardano-db-sync-docker + cardano-smash-server-docker; + } // lib.optionalAttrs (system == "x86_64-darwin") { + inherit cardano-db-sync-macos; + } // { + inherit cardano-smash-server-no-basic-auth; + checks = staticChecks; + }; + in rec { checks = staticChecks; hydraJobs = callPackages inputs.iohkNix.utils.ciJobsAggregates { - ciJobs = flake.hydraJobs; + ciJobs = flake.hydraJobs // extraCiJobs; nonRequiredPaths = map lib.hasPrefix nonRequiredPaths; - } // lib.optionalAttrs (system == "x86_64-linux") { - inherit - cardano-db-sync-linux - cardano-db-sync-docker - cardano-smash-server-docker; - } // lib.optionalAttrs (system == "x86_64-darwin") { - inherit cardano-db-sync-macos; - } // { - inherit cardano-smash-server-no-basic-auth; - checks = staticChecks; - }; + } // extraCiJobs; legacyPackages = pkgs;