diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 040c666c..91d9588a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,9 @@ on: repo: required: true type: string + fork_pr: + default: false + type: boolean secrets: SIGNING_SECRET: required: true @@ -27,10 +30,15 @@ jobs: steps: - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 + if: ${{ ! inputs.fork_pr }} with: use-cache: false + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + if: ${{ ! inputs.fork_pr }} + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + if: ${{ ! inputs.fork_pr }} with: persist-credentials: false fetch-depth: 0 @@ -39,6 +47,7 @@ jobs: - name: Login to GitHub Container Registry + if: ${{ ! inputs.fork_pr }} uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io @@ -46,9 +55,10 @@ jobs: password: ${{ github.token }} - name: Run build + if: ${{ ! inputs.fork_pr }} id: build run: | - earth --ci --push -P +prebuild + just image-prebuild-publish amd64-prebuild: timeout-minutes: 20 @@ -58,11 +68,16 @@ jobs: steps: - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 + if: ${{ ! inputs.fork_pr }} with: use-cache: false + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + if: ${{ ! inputs.fork_pr }} + # Setup repo and add caching - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + if: ${{ ! inputs.fork_pr }} with: persist-credentials: false fetch-depth: 0 @@ -72,6 +87,7 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + if: ${{ ! inputs.fork_pr }} with: registry: ghcr.io username: ${{ github.actor }} @@ -80,8 +96,9 @@ jobs: - name: Run build id: build + if: ${{ ! inputs.fork_pr }} run: | - earth --ci --push -P +prebuild + just image-prebuild-publish build-images: permissions: @@ -107,6 +124,8 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + # Setup repo and add caching - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: @@ -118,33 +137,39 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + if: ${{ ! inputs.fork_pr }} with: registry: ghcr.io username: ${{ github.actor }} password: ${{ github.token }} - - name: Run build + if: ${{ ! inputs.fork_pr }} env: GH_ACTOR: ${{ github.actor }} GH_TOKEN: ${{ github.token }} COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }} run: | - earth \ - --secret COSIGN_PRIVATE_KEY \ - --secret GH_ACTOR \ - --secret GH_TOKEN \ - --push --ci -P +build-images-all - earth \ - --artifact +sign-all/digest-list ./digest-list + if [ -n "${COSIGN_PRIVATE_KEY}" ]; then + just image-sign-publish + else + just image-publish + fi + + - name: Run build + if: ${{ inputs.fork_pr }} + run: | + just image-build - name: Store image digest info + if: ${{ ! inputs.fork_pr }} id: image_manifest_metadata run: | digest_list_json=$(jq -Rc '[ inputs | split(",") | {"image_ref":.[0],"image_digest":.[1]} ]' ./digest-list) echo "digests=$digest_list_json" >> $GITHUB_OUTPUT provenance: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} needs: [build-images] permissions: actions: read # for detecting the Github Actions environment. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 057ccd79..2cdc1bf1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,6 @@ on: jobs: build: uses: ./.github/workflows/build.yml - if: github.repository == 'blue-build/cli' permissions: contents: read # read repo contents packages: write # write package to ghcr diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index be03f4fa..2b89403d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,6 @@ on: jobs: build: uses: ./.github/workflows/build.yml - if: github.repository == 'blue-build/cli' permissions: contents: read # read repo contents packages: write # write package to ghcr @@ -21,6 +20,7 @@ jobs: with: repo: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + fork_pr: ${{ github.event.pull_request.head.repo.full_name != github.repository }} secrets: SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }} test: @@ -33,5 +33,6 @@ jobs: repo: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} pr_event_number: ${{ github.event.number }} + fork_pr: ${{ github.event.pull_request.head.repo.full_name != github.repository }} secrets: TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml new file mode 100644 index 00000000..c92fdb35 --- /dev/null +++ b/.github/workflows/run-test.yml @@ -0,0 +1,109 @@ +on: + workflow_call: + inputs: + ref: + required: true + type: string + repo: + required: true + type: string + run: + required: true + type: string + pr_event_number: + type: string + fork_pr: + default: false + type: boolean + registry_login: + default: false + type: boolean + install_qemu: + default: false + type: boolean + install_docker: + default: false + type: boolean + install_earthbuild: + default: false + type: boolean + secrets: + TEST_SIGNING_SECRET: + required: true + description: The cosign private key used to sign images for tests +env: + FORCE_COLOR: 1 + CLICOLOR_FORCE: 1 + RUST_LOG_STYLE: always + +permissions: {} + +jobs: + run-test: + name: ${{ inputs.run }} + timeout-minutes: 60 + runs-on: ubuntu-latest + permissions: + contents: read # read repo contents + packages: write # write test package to ghcr + id-token: write # docker auth + + steps: + - name: Maximize build space + uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 + with: + skip-if-available: "64G" + + - name: Set up Docker Buildx + if: ${{ inputs.install_docker }} + uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 + with: + install: true + + - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 + if: ${{ inputs.install_earthbuild }} + with: + use-cache: false + + - name: Set up QEMU + if: ${{ inputs.install_qemu }} + uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 + + - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + + - name: Login to GitHub Container Registry + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + if: ${{ ! inputs.fork_pr && inputs.registry_login }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + # Setup repo and add caching + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + fetch-depth: 0 + ref: ${{ inputs.ref }} + repository: ${{ inputs.repo }} + + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + + - name: Run ${{ inputs.run }} + if: ${{ ! inputs.fork_pr }} + env: + GH_TOKEN: ${{ github.token }} + GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} + COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} + RUN_JUST_RECIPE: ${{ inputs.run }} + run: just "${RUN_JUST_RECIPE}" + + - name: Run ${{ inputs.run }} Fork PR + if: ${{ inputs.fork_pr }} + env: + GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} + RUN_JUST_RECIPE: ${{ inputs.run }} + run: | + export CARGO_HOME=$HOME/.cargo + just "${RUN_JUST_RECIPE}" + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f1ff602..45dd9130 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,9 @@ on: type: string pr_event_number: type: string + fork_pr: + default: false + type: boolean secrets: TEST_SIGNING_SECRET: required: true @@ -18,7 +21,10 @@ env: CLICOLOR_FORCE: 1 RUST_LOG_STYLE: always -permissions: {} +permissions: + contents: read # read repo contents + packages: write # write test package to ghcr + id-token: write # docker auth jobs: test: @@ -65,8 +71,6 @@ jobs: earth --ci +lint integration-tests: - permissions: - packages: write # needed to write integ test packages timeout-minutes: 60 runs-on: ubuntu-latest @@ -95,1003 +99,290 @@ jobs: earth --ci -P ./integration-tests+all docker-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-docker-build - - recipe-v2: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-recipe-v2-build - - empty-files-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-empty-files-build - - env-expand-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-env-expansion-build - - bluefin-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-bluefin-build - - chunkah-build: - timeout-minutes: 40 - runs-on: ubuntu-24.04 - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - with: - install-dir: /usr/bin - use-sudo: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: | - export CARGO_HOME=$HOME/.cargo - just test-chunkah-build - - build-chunked-oci-build: - timeout-minutes: 40 - runs-on: ubuntu-24.04 - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - with: - install-dir: /usr/bin - use-sudo: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: | - export CARGO_HOME=$HOME/.cargo - just test-build-chunked-oci-build - - rechunk-build: - timeout-minutes: 40 - runs-on: ubuntu-24.04 - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - with: - install-dir: /usr/bin - use-sudo: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: | - export CARGO_HOME=$HOME/.cargo - just test-fresh-rechunk-build - just test-rechunk-build - - arm64-build: - timeout-minutes: 90 - runs-on: ubuntu-24.04-arm - # runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-arm64-build - - docker-build-external-login: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - name: Docker Login - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - if: inputs.repo == 'blue-build/cli' - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ github.token }} - - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-docker-build-external-login - - podman-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-podman-build - - buildah-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - # Setup repo and add caching - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-buildah-build - - multi-platform-docker: - timeout-minutes: 90 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-docker - - multi-platform-podman: - timeout-minutes: 90 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-podman - - multi-platform-buildah: - timeout-minutes: 90 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_docker: true + run: test-docker-build - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 + recipe-v2: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-recipe-v2-build - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + empty-files-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-empty-files-build - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} + env-expand-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-env-expansion-build + bluefin-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-bluefin-build - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + chunkah-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-chunkah-build - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-buildah + build-chunked-oci-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-build-chunked-oci-build - multi-platform-chunkah: - timeout-minutes: 120 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write + rechunk-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-rechunk-build - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" + arm64-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-arm64-build - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 + docker-build-external-login: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + registry_login: true + install_docker: true + run: test-docker-build-external-login - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 + podman-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-podman-build - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + buildah-build: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-buildah-build - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} + multi-platform-docker: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_docker: true + install_qemu: true + run: test-multiplatform-docker + multi-platform-podman: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_qemu: true + run: test-multiplatform-podman - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 + multi-platform-buildah: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_qemu: true + run: test-multiplatform-buildah - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-chunkah + multi-platform-chunkah: + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_qemu: true + run: test-multiplatform-chunkah multi-platform-build-chunked-oci: - timeout-minutes: 120 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-build-chunked-oci + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_qemu: true + run: test-multiplatform-build-chunked-oci multi-platform-rechunk: - timeout-minutes: 120 - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - name: Set up QEMU - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-multiplatform-rechunk + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_qemu: true + run: test-multiplatform-rechunk iso-from-image: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-generate-iso-image + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-generate-iso-image iso-from-image-web-ui: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-generate-iso-web-ui + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-generate-iso-web-ui iso-from-recipe: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-generate-iso-image + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + run: test-generate-iso-image container-podman-build: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 - with: - use-cache: false - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-container-podman-build + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_earthbuild: true + run: test-container-podman-build container-podman-chunkah: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 - with: - use-cache: false - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-container-podman-chunkah + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_earthbuild: true + run: test-container-podman-chunkah container-podman-build-chunked-oci: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 - with: - use-cache: false - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-container-podman-build-chunked-oci + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_earthbuild: true + run: test-container-podman-build-chunked-oci container-podman-rechunk: - timeout-minutes: 60 - runs-on: ubuntu-latest - permissions: - contents: read # read repo contents - packages: write # write test package to ghcr - id-token: write # docker auth - - steps: - - name: Maximize build space - uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2 - with: - skip-if-available: "64G" - - - uses: EarthBuild/actions-setup@f4d20223e70dbb43b5fc08c4d857ab9cf0dbf3ae # v2.2.0 - with: - use-cache: false - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - with: - install: true - - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - fetch-depth: 0 - ref: ${{ inputs.ref }} - repository: ${{ inputs.repo }} - - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 - - - name: Run Build - env: - GH_TOKEN: ${{ github.token }} - GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} - COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} - run: just test-container-podman-rechunk + uses: ./.github/workflows/run-test.yml + secrets: + TEST_SIGNING_SECRET: ${{ secrets.TEST_SIGNING_SECRET }} + with: + repo: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + fork_pr: ${{ inputs.fork_pr }} + pr_event_number: ${{ inputs.pr_event_number }} + install_earthbuild: true + run: test-container-podman-rechunk diff --git a/Earthfile b/Earthfile index b913b4b4..28f42aff 100644 --- a/Earthfile +++ b/Earthfile @@ -3,7 +3,12 @@ VERSION 0.8 IMPORT github.com/blue-build/earthly-lib/rust AS rust FROM alpine -ARG --global IMAGE=ghcr.io/blue-build/cli +ARG --global SUFFIX_LIST="- distrobox installer" +ARG --global EARTH_GIT_PROJECT_NAME +ARG --global EARTH_GIT_HASH +ARG --global EARTH_GIT_BRANCH +ARG --global FEDORA_VERSION="44" +ARG --global IMAGE="ghcr.io/${EARTH_GIT_PROJECT_NAME}" ARG --global TAGGED="false" ARG --global LATEST="false" @@ -24,13 +29,12 @@ build-images-all: END ARG EARTH_PUSH - IF [ "$EARTH_PUSH" = "true" ] - BUILD --pass-args +sign-all + ARG SIGN + IF [ "$EARTH_PUSH" = "true" ] && [ "$SIGN" = "true" ] + BUILD --pass-args +sign-images END -sign-all: - ARG SUFFIX_LIST="- distrobox installer" - BUILD --pass-args +sign-images +local-digest-list: COPY --pass-args +digest-list/digest-list / SAVE ARTIFACT /digest-list AS LOCAL ./digest-list @@ -85,7 +89,7 @@ EACH_FEAT: install: FROM +common ARG --required BUILD_TARGET - ARG --required RELEASE + ARG RELEASE IF [ "$RELEASE" = "true" ] DO rust+CROSS --target="$BUILD_TARGET" --output="$BUILD_TARGET/release/[^\./]+" @@ -98,7 +102,7 @@ install: install-all-features: FROM +common ARG --required BUILD_TARGET - ARG --required RELEASE + ARG RELEASE IF [ "$RELEASE" = "true" ] DO rust+CROSS --args="build --all-features --release" --target="$BUILD_TARGET" --output="$BUILD_TARGET/release/[^\./]+" @@ -136,7 +140,7 @@ common: DO rust+INIT --keep_fingerprints=true blue-build-cli-prebuild: - ARG BASE_IMAGE="registry.fedoraproject.org/fedora-toolbox:42" + ARG BASE_IMAGE="registry.fedoraproject.org/fedora-toolbox:${FEDORA_VERSION}" FROM "$BASE_IMAGE" RUN dnf5 -y update \ @@ -188,17 +192,15 @@ blue-build-cli-prebuild: ENTRYPOINT ["/usr/bin/dumb-init", "--"] - ARG EARTH_GIT_HASH ARG TARGETARCH SAVE IMAGE --push "$IMAGE:$EARTH_GIT_HASH-prebuild-$TARGETARCH" blue-build-cli: FROM alpine - ARG RELEASE="true" + ARG RELEASE ARG TARGETARCH IF [ "$RELEASE" = "true" ] - ARG EARTH_GIT_HASH FROM "$IMAGE:$EARTH_GIT_HASH-prebuild-$TARGETARCH" ELSE FROM +blue-build-cli-prebuild @@ -235,14 +237,18 @@ blue-build-cli-distrobox-prebuild: COPY +cosign/cosign /usr/bin/cosign - ARG EARTH_GIT_HASH ARG TARGETARCH SAVE IMAGE --push "$IMAGE:$EARTH_GIT_HASH-distrobox-prebuild-$TARGETARCH" blue-build-cli-distrobox: - ARG EARTH_GIT_HASH + ARG RELEASE ARG TARGETARCH - FROM "$IMAGE:$EARTH_GIT_HASH-distrobox-prebuild-$TARGETARCH" + + IF [ "$RELEASE" = "true" ] + FROM "$IMAGE:$EARTH_GIT_HASH-distrobox-prebuild-$TARGETARCH" + ELSE + FROM +blue-build-cli-distrobox-prebuild + END DO +INSTALL --OUT_DIR="/usr/bin/" --BUILD_TARGET="$(uname -m)-unknown-linux-musl" @@ -263,13 +269,19 @@ installer: DO +INSTALL --OUT_DIR="/out/" --BUILD_TARGET="x86_64-unknown-linux-musl" END - COPY install.sh /install.sh + COPY +modify-installer/install.sh /install.sh CMD ["cat", "/install.sh"] DO --pass-args +SAVE_IMAGE --SUFFIX="-installer" SAVE ARTIFACT /out/bluebuild +modify-installer: + FROM --platform native alpine + COPY install.sh /install.sh + RUN sed -i "s|^PROJECT=\"blue-build/cli\"|PROJECT=\"${EARTH_GIT_PROJECT_NAME}\"|" /install.sh + SAVE ARTIFACT /install.sh + cosign: FROM ghcr.io/sigstore/cosign/cosign:v3.1.3 SAVE ARTIFACT /ko-app/cosign @@ -305,8 +317,6 @@ digest-list: LET minor_version="$(echo "$version" | cut -d'.' -f2)" ARG --required SUFFIX_LIST - ARG EARTH_GIT_HASH - ARG EARTH_GIT_BRANCH LET suffix="" FOR s IN $SUFFIX_LIST @@ -396,19 +406,17 @@ SAVE_IMAGE: SAVE IMAGE --push "${IMAGE}:v${major_version}${SUFFIX}" END ELSE - ARG EARTH_GIT_BRANCH ARG IMAGE_TAG="$(echo "${EARTH_GIT_BRANCH}" | sed 's|/|_|g')" SAVE IMAGE --push "${IMAGE}:${IMAGE_TAG}${SUFFIX}" END - ARG EARTH_GIT_HASH SAVE IMAGE --push "${IMAGE}:${EARTH_GIT_HASH}${SUFFIX}" LABELS: FUNCTION LET build_time="$(date -Iseconds)" LABEL org.opencontainers.image.created="$build_time" - LABEL org.opencontainers.image.url="https://github.com/blue-build/cli" - LABEL org.opencontainers.image.source="https://github.com/blue-build/cli" + LABEL org.opencontainers.image.url="https://github.com/${EARTH_GIT_PROJECT_NAME}" + LABEL org.opencontainers.image.source="https://github.com/${EARTH_GIT_PROJECT_NAME}" LABEL org.opencontainers.image.version="$VERSION" LABEL version="$VERSION" LABEL org.opencontainers.image.vendor="BlueBuild" @@ -416,12 +424,11 @@ LABELS: LABEL org.opencontainers.image.licenses="Apache-2.0" LABEL license="Apache-2.0" LABEL org.opencontainers.image.title="BlueBuild CLI tool" - LABEL name="blue-build/cli" + LABEL name="${EARTH_GIT_PROJECT_NAME}" LABEL org.opencontainers.image.description="A CLI tool built for creating Containerfile templates for ostree based atomic distros" - LABEL org.opencontainers.image.documentation="https://raw.githubusercontent.com/blue-build/cli/main/README.md" + LABEL org.opencontainers.image.documentation="https://raw.githubusercontent.com/${EARTH_GIT_PROJECT_NAME}/main/README.md" IF [ "$TAGGED" = "true" ] - ARG EARTH_GIT_BRANCH LABEL org.opencontainers.image.ref.name="$EARTH_GIT_BRANCH" ELSE LABEL org.opencontainers.image.ref.name="v$VERSION" diff --git a/install.sh b/install.sh index c2942283..3bd135ae 100755 --- a/install.sh +++ b/install.sh @@ -3,6 +3,7 @@ set -euo pipefail VERSION=v0.9.37 +PROJECT="blue-build/cli" # Container runtime function cr() { @@ -16,12 +17,11 @@ function cr() { fi } -# We use sudo for podman so that we can copy directly into /usr/local/bin function cleanup() { echo "Cleaning up image" cr rm blue-build-installer sleep 2 - cr image rm ghcr.io/blue-build/cli:${VERSION}-installer + cr image rm ghcr.io/${PROJECT}:${VERSION}-installer } trap cleanup SIGINT @@ -31,21 +31,23 @@ if command -v cosign &> /dev/null then PUBKEY_DIR=$(mktemp -d) PUBKEY_FILE="${PUBKEY_DIR}/cosign.pub" - curl -Lo "${PUBKEY_FILE}" https://raw.githubusercontent.com/blue-build/cli/refs/heads/main/cosign.pub - cosign verify --key "${PUBKEY_FILE}" "ghcr.io/blue-build/cli:${VERSION}-installer" + curl -Lo "${PUBKEY_FILE}" https://raw.githubusercontent.com/${PROJECT}/refs/heads/main/cosign.pub + cosign verify --key "${PUBKEY_FILE}" "ghcr.io/${PROJECT}:${VERSION}-installer" fi cr create \ --pull always \ --name blue-build-installer \ - ghcr.io/blue-build/cli:${VERSION}-installer + ghcr.io/${PROJECT}:${VERSION}-installer set +e +set -x cr cp blue-build-installer:/out/bluebuild /tmp/ sudo mv /tmp/bluebuild /usr/local/bin/ RETVAL=$? +set +x set -e if [ $RETVAL != 0 ]; then diff --git a/integration-tests/Earthfile b/integration-tests/Earthfile index aedf6f33..fa91dc13 100644 --- a/integration-tests/Earthfile +++ b/integration-tests/Earthfile @@ -90,7 +90,7 @@ init: --no-git legacy-base: - FROM ../+blue-build-cli --RELEASE=false + FROM ../+blue-build-cli ENV BB_TEST_LOCAL_IMAGE=localhost/cli/test:latest ENV CLICOLOR_FORCE=1 @@ -105,7 +105,7 @@ legacy-base: ENV USER=root test-base: - FROM ../+blue-build-cli --RELEASE=false + FROM ../+blue-build-cli RUN git config --global user.email "you@example.com" && \ git config --global user.name "Your Name" diff --git a/integration-tests/legacy-test-repo/config/recipe.yml b/integration-tests/legacy-test-repo/config/recipe.yml index 9593ec9c..2feecd42 100644 --- a/integration-tests/legacy-test-repo/config/recipe.yml +++ b/integration-tests/legacy-test-repo/config/recipe.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-legacy +name: ${BB_TEST_IMAGE_NAME:-cli}/test-legacy description: This is my personal OS image. base-image: ghcr.io/ublue-os/silverblue-surface image-version: gts diff --git a/integration-tests/test-repo/recipes/recipe-arm64.yml b/integration-tests/test-repo/recipes/recipe-arm64.yml index 72c1adb6..c176ad5b 100644 --- a/integration-tests/test-repo/recipes/recipe-arm64.yml +++ b/integration-tests/test-repo/recipes/recipe-arm64.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-arm64 +name: ${BB_TEST_IMAGE_NAME:-cli}/test-arm64 description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-bluefin.yml b/integration-tests/test-repo/recipes/recipe-bluefin.yml index 7cc62c5a..c3bb7e15 100644 --- a/integration-tests/test-repo/recipes/recipe-bluefin.yml +++ b/integration-tests/test-repo/recipes/recipe-bluefin.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-bluefin +name: ${BB_TEST_IMAGE_NAME:-cli}/test-bluefin description: This is my personal OS image. base-image: ghcr.io/ublue-os/bluefin blue-build-tag: none diff --git a/integration-tests/test-repo/recipes/recipe-build-chunked-oci.yml b/integration-tests/test-repo/recipes/recipe-build-chunked-oci.yml index a1468ab4..8c16e970 100644 --- a/integration-tests/test-repo/recipes/recipe-build-chunked-oci.yml +++ b/integration-tests/test-repo/recipes/recipe-build-chunked-oci.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-build-chunked-oci +name: ${BB_TEST_IMAGE_NAME:-cli}/test-build-chunked-oci description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-buildah.yml b/integration-tests/test-repo/recipes/recipe-buildah.yml index eb88cf30..50b3af7e 100644 --- a/integration-tests/test-repo/recipes/recipe-buildah.yml +++ b/integration-tests/test-repo/recipes/recipe-buildah.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-buildah +name: ${BB_TEST_IMAGE_NAME:-cli}/test-buildah description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-chunkah.yml b/integration-tests/test-repo/recipes/recipe-chunkah.yml index 9ba40d81..79cf58cf 100644 --- a/integration-tests/test-repo/recipes/recipe-chunkah.yml +++ b/integration-tests/test-repo/recipes/recipe-chunkah.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-chunkah +name: ${BB_TEST_IMAGE_NAME:-cli}/test-chunkah description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-docker-external.yml b/integration-tests/test-repo/recipes/recipe-docker-external.yml index 388bb296..467ad6b6 100644 --- a/integration-tests/test-repo/recipes/recipe-docker-external.yml +++ b/integration-tests/test-repo/recipes/recipe-docker-external.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-docker-external +name: ${BB_TEST_IMAGE_NAME:-cli}/test-docker-external description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-env-expansion.yml b/integration-tests/test-repo/recipes/recipe-env-expansion.yml index 317957bb..177c81ab 100644 --- a/integration-tests/test-repo/recipes/recipe-env-expansion.yml +++ b/integration-tests/test-repo/recipes/recipe-env-expansion.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-${NAME_EXT:-env-expansion} +name: ${BB_TEST_IMAGE_NAME:-cli}/test-${NAME_EXT:-env-expansion} description: This is my personal OS image. ${DESC_EXT} base-image: ${BASE_REGISTRY:-quay.io}/fedora/fedora-bootc blue-build-tag: none diff --git a/integration-tests/test-repo/recipes/recipe-gts.yml b/integration-tests/test-repo/recipes/recipe-gts.yml index 212e67c8..d3c33eb3 100644 --- a/integration-tests/test-repo/recipes/recipe-gts.yml +++ b/integration-tests/test-repo/recipes/recipe-gts.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test +name: ${BB_TEST_IMAGE_NAME:-cli}/test description: This is my personal OS image. base-image: ghcr.io/ublue-os/silverblue-main nushell-version: none diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-build-chunked-oci.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-build-chunked-oci.yml index 10069581..7c3065fb 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-build-chunked-oci.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-build-chunked-oci.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-build-chunked-oci +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-build-chunked-oci description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-buildah.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-buildah.yml index b3f2cc2c..4bc5823c 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-buildah.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-buildah.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-buildah +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-buildah description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-chunkah.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-chunkah.yml index ce64bd93..ac35f313 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-chunkah.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-chunkah.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-chunkah +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-chunkah description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-docker.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-docker.yml index 6e360dde..8a20fd4f 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-docker.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-docker.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-docker +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-docker description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-podman.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-podman.yml index 896d8974..da8c40e4 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-podman.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-podman.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-podman +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-podman description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-multiplatform-rechunk.yml b/integration-tests/test-repo/recipes/recipe-multiplatform-rechunk.yml index 204ab53d..84f039ae 100644 --- a/integration-tests/test-repo/recipes/recipe-multiplatform-rechunk.yml +++ b/integration-tests/test-repo/recipes/recipe-multiplatform-rechunk.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-multiplatform-rechunk +name: ${BB_TEST_IMAGE_NAME:-cli}/test-multiplatform-rechunk description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-podman.yml b/integration-tests/test-repo/recipes/recipe-podman.yml index 93ddb707..d98efbe4 100644 --- a/integration-tests/test-repo/recipes/recipe-podman.yml +++ b/integration-tests/test-repo/recipes/recipe-podman.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-podman +name: ${BB_TEST_IMAGE_NAME:-cli}/test-podman description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-rechunk.yml b/integration-tests/test-repo/recipes/recipe-rechunk.yml index 699320f1..8be102a9 100644 --- a/integration-tests/test-repo/recipes/recipe-rechunk.yml +++ b/integration-tests/test-repo/recipes/recipe-rechunk.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test-rechunk +name: ${BB_TEST_IMAGE_NAME:-cli}/test-rechunk description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc image-version: latest diff --git a/integration-tests/test-repo/recipes/recipe-v2.yml b/integration-tests/test-repo/recipes/recipe-v2.yml index 8889f37f..54aacb14 100644 --- a/integration-tests/test-repo/recipes/recipe-v2.yml +++ b/integration-tests/test-repo/recipes/recipe-v2.yml @@ -7,7 +7,7 @@ base: repository: fedora/fedora-bootc tag: latest metadata: - name: cli/test-recipe-v2 + name: ${BB_TEST_IMAGE_NAME:-cli}/test-recipe-v2 description: This is my personal OS image. spec: tool-versions: diff --git a/integration-tests/test-repo/recipes/recipe.yml b/integration-tests/test-repo/recipes/recipe.yml index 901e9d84..08db0de2 100644 --- a/integration-tests/test-repo/recipes/recipe.yml +++ b/integration-tests/test-repo/recipes/recipe.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json -name: cli/test +name: ${BB_TEST_IMAGE_NAME:-cli}/test description: This is my personal OS image. base-image: quay.io/fedora/fedora-bootc blue-build-tag: none diff --git a/justfile b/justfile index 3a52a34d..8d7467aa 100644 --- a/justfile +++ b/justfile @@ -5,6 +5,7 @@ export BB_SKIP_VALIDATION := "true" set dotenv-load := true set positional-arguments := true +set lazy # default recipe to display help information default: @@ -88,6 +89,33 @@ watch-lint: watch-lint-all-features: cargo watch -c -x 'clippy --all-features' +# Build the images and store locally +image-build: + earth --output --platform native --ci -P +build-images + +image-prebuild: + earth --ci +prebuild + +image-prebuild-publish: + earth --ci --push +prebuild + +image-publish: && image-digest + earth \ + --push --ci -P +build-images-all \ + --RELEASE="true" + +image-sign-publish: && image-digest + earth \ + --secret COSIGN_PRIVATE_KEY \ + --secret GH_ACTOR \ + --secret GH_TOKEN \ + --push --ci -P +build-images-all \ + --SIGN="true" \ + --RELEASE="true" + +image-digest: + earth +local-digest-list + # Expand the macros of a module for debugging expand *args: cargo expand $@ > ./expand.rs @@ -124,7 +152,7 @@ release *args: gh release create --generate-notes --latest "v${VERSION}" should_push := if env('GITHUB_ACTIONS', '') != '' { - if env('COSIGN_PRIVATE_KEY', '') != '' { + if env('GH_TOKEN', '') != '' { '--push' } else { '' @@ -133,12 +161,22 @@ should_push := if env('GITHUB_ACTIONS', '') != '' { '' } +should_not_sign := if env('COSIGN_PRIVATE_KEY', '') == '' { + '--no-sign' +} else { + '' +} + +project_path := `git remote get-url origin | sed -E 's|^[^:/]+://[^/]*/||; s|^.*:||; s/\.git$//'` + cargo_bin := if env('CARGO_HOME', '') != '' { - x"${CARGO_HOME:-}/bin" + x"${CARGO_HOME:-}/bin/bluebuild" } else { - x"$HOME/.cargo/bin" + x"$HOME/.cargo/bin/bluebuild" } +export BB_TEST_IMAGE_NAME := file_stem(project_path) + generate-test-secret: mkdir -p integration-tests/test-repo/secrets echo "321tset" > integration-tests/test-repo/secrets/test-secret @@ -149,82 +187,91 @@ integration-tests: generate-test-secret test-docker-build test-empty-files-build # Run docker driver integration test test-docker-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B docker \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe.yml recipes/recipe-gts.yml test-recipe-v2-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-v2.yml test-empty-files-build: generate-test-secret install-debug-all-features cd integration-tests/empty-files-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B docker \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv test-env-expansion-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ && DESC_EXT="Test description" \ VERSION="43" \ - bluebuild build \ + {{ cargo_bin }} build \ --retry-push \ -B docker \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-env-expansion.yml test-bluefin-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B docker \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-bluefin.yml test-chunkah-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ --chunkah \ recipes/recipe-chunkah.yml test-build-chunked-oci-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ --build-chunked-oci \ recipes/recipe-build-chunked-oci.yml test-rechunk-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ --rechunk \ recipes/recipe-rechunk.yml test-fresh-rechunk-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ --rechunk \ --rechunk-clear-plan \ @@ -233,42 +280,46 @@ test-fresh-rechunk-build: generate-test-secret install-debug-all-features # Run arm integration test test-arm64-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ --platform linux/arm64 \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-arm64.yml # Run docker driver external login integration test test-docker-build-external-login: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-docker-external.yml # Run podman driver integration test test-podman-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B podman \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-podman.yml # Run buildah driver integration test test-buildah-build: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B buildah \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-buildah.yml @@ -277,63 +328,69 @@ test-multiplatform: test-multiplatform-docker test-multiplatform-podman test-mul test-multiplatform-docker: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B docker \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-docker.yml test-multiplatform-podman: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B podman \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-podman.yml test-multiplatform-buildah: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ -B buildah \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-buildah.yml test-multiplatform-chunkah: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ --chunkah \ --remove-base-image \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-chunkah.yml test-multiplatform-build-chunked-oci: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ --build-chunked-oci \ --remove-base-image \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-build-chunked-oci.yml test-multiplatform-rechunk: generate-test-secret install-debug-all-features cd integration-tests/test-repo \ - && bluebuild build \ + && {{ cargo_bin }} build \ --retry-push \ --rechunk \ -S sigstore \ {{ should_push }} \ + {{ should_not_sign }} \ -vv \ recipes/recipe-multiplatform-rechunk.yml @@ -342,14 +399,14 @@ test-generate-iso-image: generate-test-secret install-debug-all-features #!/usr/bin/env bash set -eu ISO_OUT=$(mktemp -d) - bluebuild generate-iso -vv --output-dir "$ISO_OUT" image ghcr.io/blue-build/cli/test:latest + {{ cargo_bin }} generate-iso -vv --output-dir "$ISO_OUT" image ghcr.io/{{ project_path }}/test:latest # Run ISO generator for images using web-ui test-generate-iso-web-ui: generate-test-secret install-debug-all-features #!/usr/bin/env bash set -eu ISO_OUT=$(mktemp -d) - bluebuild generate-iso -vv --output-dir "$ISO_OUT" --web-ui image ghcr.io/blue-build/cli/test:latest + {{ cargo_bin }} generate-iso -vv --output-dir "$ISO_OUT" --web-ui image ghcr.io/{{ project_path }}/test:latest # Run ISO generator for images test-generate-iso-recipe: generate-test-secret install-debug-all-features @@ -357,11 +414,11 @@ test-generate-iso-recipe: generate-test-secret install-debug-all-features set -eu ISO_OUT=$(mktemp -d) cd integration-tests/test-repo - bluebuild generate-iso -vv --output-dir "$ISO_OUT" recipe recipes/recipe.yml + {{ cargo_bin }} generate-iso -vv --output-dir "$ISO_OUT" recipe recipes/recipe.yml # Build a local cli image build-local-cli-image: - earth --ci --output -P +blue-build-cli --RELEASE='false' + earth --ci --output -P +blue-build-cli git_sha := `git rev-parse HEAD` tty_arg := `[ -t 0 ] && echo "t" || echo ""` @@ -371,7 +428,7 @@ exec-cli-container +args: build-local-cli-image docker run -i{{ tty_arg }} --privileged --rm \ -v ./integration-tests/test-repo:/bluebuild \ -e TEST_SECRET="$TEST_SECRET" \ - ghcr.io/blue-build/cli:{{ git_sha }} \ + ghcr.io/{{ project_path }}:{{ git_sha }} \ {{ args }} # Run a cli container using the podman build driver diff --git a/process/drivers/github_driver.rs b/process/drivers/github_driver.rs index 18e33d8b..57b8b8e7 100644 --- a/process/drivers/github_driver.rs +++ b/process/drivers/github_driver.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use blue_build_utils::{ constants::{ - GITHUB_EVENT_NAME, GITHUB_EVENT_PATH, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_TOKEN_ISSUER_URL, + GITHUB_EVENT_NAME, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_TOKEN_ISSUER_URL, GITHUB_WORKFLOW_REF, PR_EVENT_NUMBER, }, container::Tag, @@ -24,10 +24,21 @@ mod event; pub struct GithubDriver; +impl GithubDriver { + fn is_pull_request() -> bool { + get_env_var(GITHUB_EVENT_NAME) + .inspect(|v| trace!("{GITHUB_EVENT_NAME}={v}")) + .is_ok_and(|val| val == "pull_request") + } + + fn get_pr_number() -> Result { + get_env_var(PR_EVENT_NUMBER).inspect(|v| trace!("{PR_EVENT_NUMBER}={v}")) + } +} + impl CiDriver for GithubDriver { fn on_default_branch() -> bool { - get_env_var(GITHUB_EVENT_PATH) - .is_ok_and(|path| Event::try_new(path).is_ok_and(|e| e.on_default_branch())) + Event::read_from_env().is_ok_and(|e| e.on_default_branch()) } fn keyless_cert_identity() -> Result { @@ -39,7 +50,6 @@ impl CiDriver for GithubDriver { } fn generate_tags(opts: GenerateTagsOpts) -> Result> { - const PR_EVENT: &str = "pull_request"; let timestamp = blue_build_utils::get_tag_timestamp(); let os_version = Driver::get_os_version() .oci_ref(opts.oci_ref) @@ -57,9 +67,24 @@ impl CiDriver for GithubDriver { let tags = match ( Self::on_default_branch(), opts.alt_tags.as_ref(), - get_env_var(GITHUB_EVENT_NAME).inspect(|v| trace!("{GITHUB_EVENT_NAME}={v}")), - get_env_var(PR_EVENT_NUMBER).inspect(|v| trace!("{PR_EVENT_NUMBER}={v}")), + Self::is_pull_request(), + Self::get_pr_number(), ) { + (false, None, true, Ok(event_num)) => { + vec![ + format!("pr-{event_num}-{os_version}"), + format!("{short_sha}-{os_version}"), + ] + } + (false, Some(alt_tags), true, Ok(event_num)) => alt_tags + .iter() + .flat_map(|alt| { + vec![ + format!("pr-{event_num}-{alt}-{os_version}"), + format!("{short_sha}-{alt}-{os_version}"), + ] + }) + .collect(), (true, None, _, _) => { string_vec![ "latest", @@ -80,29 +105,12 @@ impl CiDriver for GithubDriver { ] }) .collect(), - (false, None, Ok(event_name), Ok(event_num)) if event_name == PR_EVENT => { - vec![ - format!("pr-{event_num}-{os_version}"), - format!("{short_sha}-{os_version}"), - ] - } (false, None, _, _) => { vec![ format!("br-{ref_name}-{os_version}"), format!("{short_sha}-{os_version}"), ] } - (false, Some(alt_tags), Ok(event_name), Ok(event_num)) if event_name == PR_EVENT => { - alt_tags - .iter() - .flat_map(|alt| { - vec![ - format!("pr-{event_num}-{alt}-{os_version}"), - format!("{short_sha}-{alt}-{os_version}"), - ] - }) - .collect() - } (false, Some(alt_tags), _, _) => alt_tags .iter() .flat_map(|alt| { @@ -122,21 +130,18 @@ impl CiDriver for GithubDriver { } fn get_repo_url() -> miette::Result { - Ok(Event::try_new(get_env_var(GITHUB_EVENT_PATH)?)? - .repository - .html_url) + Ok(Event::read_from_env()?.repository.html_url) } fn get_registry() -> miette::Result { - Ok(format!( - "ghcr.io/{}", - Event::try_new(get_env_var(GITHUB_EVENT_PATH)?)? - .repository - .owner - .login - ) - .trim() - .to_lowercase()) + let event = Event::read_from_env()?; + + let owner = if let Some(pr) = event.pull_request { + pr.head.repo.owner.login + } else { + event.repository.owner.login + }; + Ok(format!("ghcr.io/{owner}").trim().to_lowercase()) } fn default_ci_file_path() -> PathBuf { @@ -201,7 +206,7 @@ mod test { } #[test] - fn get_registry() { + fn get_registry_default_branch() { setup_default_branch(); let registry = GithubDriver::get_registry().unwrap(); @@ -209,6 +214,15 @@ mod test { assert_eq!(registry, "ghcr.io/test-owner"); } + #[test] + fn get_registry_pr() { + setup_pr_branch(); + + let registry = GithubDriver::get_registry().unwrap(); + + assert_eq!(registry, "ghcr.io/gmpinder"); + } + #[test] fn on_default_branch_true() { setup_default_branch(); diff --git a/process/drivers/github_driver/event.rs b/process/drivers/github_driver/event.rs index e2dfa8f0..9a564487 100644 --- a/process/drivers/github_driver/event.rs +++ b/process/drivers/github_driver/event.rs @@ -1,8 +1,8 @@ -use std::path::Path; +use std::{fs, path::PathBuf}; -use blue_build_utils::constants::GITHUB_REF_NAME; -use log::debug; -use miette::{Context, IntoDiagnostic, Result}; +use blue_build_utils::constants::{GITHUB_EVENT_PATH, GITHUB_REF_NAME}; +use log::{debug, trace}; +use miette::{IntoDiagnostic, Result}; use serde::Deserialize; #[cfg(test)] @@ -17,30 +17,33 @@ pub(super) struct Event { // pub base: Option, pub head: Option, + pub pull_request: Option, + #[serde(alias = "ref")] pub commit_ref: Option, } -impl TryFrom<&str> for Event { - type Error = miette::Report; - - fn try_from(value: &str) -> std::prelude::v1::Result { - serde_json::from_str(value).into_diagnostic() - } -} - impl Event { - pub fn try_new

(path: P) -> Result - where - P: AsRef, - { - fn inner(path: &Path) -> Result { - let contents = std::fs::read_to_string(path) + /// Reads from the environment and constructs + /// itself from the event file. + /// + /// # Errors + /// Will error if the environment variable + /// `GITHUB_EVENT_PATH` doesn't exist or if + /// deserializing the event file fails. + pub fn read_from_env() -> Result { + // We cache since the event won't change during evocation + #[cached::cached()] + fn inner(path: PathBuf) -> Result { + fs::read_to_string(path) .into_diagnostic() - .with_context(|| format!("Path: {}", path.display()))?; - Event::try_from(contents.as_str()) + .inspect(|event| trace!("{event}")) + .and_then(|event| serde_json::from_str(&event).into_diagnostic()) + .inspect(|event| trace!("{event:#?}")) } - inner(path.as_ref()) + get_env_var(GITHUB_EVENT_PATH) + .map(PathBuf::from) + .and_then(inner) } pub fn on_default_branch(&self) -> bool { @@ -61,17 +64,6 @@ impl Event { } } -// impl Event { -// pub fn try_new() -> Result { -// get_env_var(GITHUB_EVENT_PATH) -// .map(PathBuf::from) -// .and_then(|event_path| { -// serde_json::from_str::(&fs::read_to_string(event_path).into_diagnostic()?) -// .into_diagnostic() -// }) -// } -// } - #[derive(Debug, Deserialize, Clone)] pub(super) struct EventRepository { pub default_branch: String, @@ -84,15 +76,24 @@ pub(super) struct EventRepositoryOwner { pub login: String, } +#[derive(Debug, Deserialize, Clone)] +pub(super) struct EventPullRequest { + pub head: EventRefInfo, +} + #[derive(Debug, Deserialize, Clone)] pub(super) struct EventRefInfo { #[serde(alias = "ref")] pub commit_ref: String, + pub repo: EventRepository, } #[cfg(test)] mod test { - use blue_build_utils::{constants::GITHUB_REF_NAME, test_utils::set_env_var}; + use blue_build_utils::{ + constants::{GITHUB_EVENT_PATH, GITHUB_REF_NAME}, + test_utils::set_env_var, + }; use rstest::rstest; use super::Event; @@ -103,9 +104,10 @@ mod test { #[case::pr("../test-files/github-events/pr-branch.json", "test", false)] #[case::branch("../test-files/github-events/branch.json", "test", false)] fn test_on_default_branch(#[case] path: &str, #[case] ref_name: &str, #[case] expected: bool) { + set_env_var(GITHUB_EVENT_PATH, path); set_env_var(GITHUB_REF_NAME, ref_name); - let event = Event::try_new(path).unwrap(); + let event = Event::read_from_env().unwrap(); eprintln!("{event:?}"); assert_eq!(expected, event.on_default_branch()); diff --git a/test-files/github-events/pr-branch.json b/test-files/github-events/pr-branch.json index 01871a76..9f9d43e6 100644 --- a/test-files/github-events/pr-branch.json +++ b/test-files/github-events/pr-branch.json @@ -1,15 +1,24 @@ { - "head": { - "ref": "test-branch" - }, - "base": { - "ref": "main" - }, - "repository": { - "default_branch": "main", - "owner": { - "login": "Test-Owner" + "pull_request": { + "head": { + "ref": "test-branch", + "repo": { + "default_branch": "main", + "owner": { + "login": "gmpinder" + }, + "html_url": "https://example.com/" + } + }, + "base": { + "ref": "main" + } }, - "html_url": "https://example.com/" - } + "repository": { + "default_branch": "main", + "owner": { + "login": "Test-Owner" + }, + "html_url": "https://example.com/" + } } \ No newline at end of file