Skip to content

ci

ci #1433

Workflow file for this run

name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
on:
schedule:
- cron: '0 3 * * 0' # every Sunday at 3:00 UTC
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
env:
GO_VERSION: 1.26
SETUP_BUILDX_VERSION: latest
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
BUILDKIT_CACHE_REPO: moby/buildkit-bench-cache
##
BUILDKIT_REPO: moby/buildkit
BUILDKIT_CANDIDATES_KEY: buildkit-candidates
BUILDKIT_ARTIFACT_KEY: buildkit-binaries
BUILDKIT_CACHE_PREFIX: bkbins
BUILDKIT_CANDIDATES_REFS: master,pr-6964,pr-6965,pr-7034
BUILDKIT_CANDIDATES_LAST_DAYS: 15
BUILDKIT_CANDIDATES_LAST_RELEASES: 8
##
BUILDX_REPO: docker/buildx
BUILDX_CANDIDATES_KEY: buildx-candidates
BUILDX_ARTIFACT_KEY: buildx-binaries
BUILDX_CACHE_PREFIX: bxbins
BUILDX_CANDIDATES_REFS: master,pr-3033
BUILDX_CANDIDATES_LAST_DAYS: 15
BUILDX_CANDIDATES_LAST_RELEASES: 8
##
GEN_VALIDATION_MODE: strict
WEBSITE_PUBLIC_PATH: /buildkit-bench/
jobs:
# limitation to using envs in a reusable workflow input
# https://github.com/actions/runner/issues/2372
get-env:
runs-on: ubuntu-24.04
outputs:
BUILDKIT_REPO: ${{ env.BUILDKIT_REPO }}
BUILDKIT_ARTIFACT_KEY: ${{ env.BUILDKIT_ARTIFACT_KEY }}
BUILDKIT_CACHE_PREFIX: ${{ env.BUILDKIT_CACHE_PREFIX }}
BUILDKIT_CANDIDATES_KEY: ${{ env.BUILDKIT_CANDIDATES_KEY }}
BUILDKIT_CANDIDATES_REFS: ${{ env.BUILDKIT_CANDIDATES_REFS }}
BUILDKIT_CANDIDATES_LAST_DAYS: ${{ env.BUILDKIT_CANDIDATES_LAST_DAYS }}
BUILDKIT_CANDIDATES_LAST_RELEASES: ${{ env.BUILDKIT_CANDIDATES_LAST_RELEASES }}
##
BUILDX_REPO: ${{ env.BUILDX_REPO }}
BUILDX_ARTIFACT_KEY: ${{ env.BUILDX_ARTIFACT_KEY }}
BUILDX_CACHE_PREFIX: ${{ env.BUILDX_CACHE_PREFIX }}
BUILDX_CANDIDATES_KEY: ${{ env.BUILDX_CANDIDATES_KEY }}
BUILDX_CANDIDATES_REFS: ${{ env.BUILDX_CANDIDATES_REFS }}
BUILDX_CANDIDATES_LAST_DAYS: ${{ env.BUILDX_CANDIDATES_LAST_DAYS }}
BUILDX_CANDIDATES_LAST_RELEASES: ${{ env.BUILDX_CANDIDATES_LAST_RELEASES }}
steps:
- run: "true"
prepare:
runs-on: ubuntu-24.04
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build tests base
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
with:
targets: tests-base
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.cache-to=type=registry,ignore-error=true,mode=max,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
buildkit-binaries:
uses: ./.github/workflows/.binaries.yml
needs:
- get-env
secrets:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
target: buildkit
repo: ${{ needs.get-env.outputs.BUILDKIT_REPO }}
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
cache_prefix: ${{ needs.get-env.outputs.BUILDKIT_CACHE_PREFIX }}
candidates_key: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_KEY }}
refs: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_REFS }}
last_days: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_LAST_DAYS }}
last_releases: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_LAST_RELEASES }}
buildx-binaries:
uses: ./.github/workflows/.binaries.yml
needs:
- get-env
secrets:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
target: buildx
repo: ${{ needs.get-env.outputs.BUILDX_REPO }}
artifact_key: ${{ needs.get-env.outputs.BUILDX_ARTIFACT_KEY }}
cache_prefix: ${{ needs.get-env.outputs.BUILDX_CACHE_PREFIX }}
candidates_key: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_KEY }}
refs: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_REFS }}
last_days: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_LAST_DAYS }}
last_releases: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_LAST_RELEASES }}
test:
runs-on: ubuntu-24.04
needs:
- prepare
- buildkit-binaries
env:
TEST_FLAGS: -v
TEST_IMAGE_BUILD: 0
TEST_IMAGE_ID: buildkit-bench
TEST_RESULTS_DIR: bin/results
steps:
-
name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/buildkit-binaries
pattern: ${{ env.BUILDKIT_ARTIFACT_KEY }}-*
merge-multiple: true
-
name: Extract binaries
run: |
mkdir -p ./bin/buildkit-binaries
for f in "/tmp/buildkit-binaries"/*.tar.gz; do
(set -x ; tar -xzvf "$f" -C ./bin/buildkit-binaries && rm "$f")
done
tree -nph ./bin/buildkit-binaries
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver: docker
-
name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
-
name: Build test image
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
with:
targets: tests-buildkit
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.contexts.buildkit-binaries=cwd://bin/buildkit-binaries
*.output=type=docker,name=${{ env.TEST_IMAGE_ID }}
-
name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
-
name: Test
run: |
make test
env:
TEST_TYPES: test
-
name: Result
run: |
resultPath=./${{ env.TEST_RESULTS_DIR }}/gotestoutput-tests.json
mv ./${{ env.TEST_RESULTS_DIR }}/gotestoutput.json $resultPath
jq . $resultPath
-
name: Upload results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: tests-results
path: ${{ env.TEST_RESULTS_DIR }}
if-no-files-found: error
retention-days: 7
benchmark-buildkit:
uses: ./.github/workflows/.benchmark.yml
needs:
- get-env
- prepare
- buildkit-binaries
with:
target: buildkit
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
benchmark-buildx:
uses: ./.github/workflows/.benchmark.yml
needs:
- get-env
- prepare
- buildx-binaries
with:
target: buildx
artifact_key: ${{ needs.get-env.outputs.BUILDX_ARTIFACT_KEY }}
report:
runs-on: ubuntu-24.04
needs:
- test
- benchmark-buildkit
- benchmark-buildx
steps:
-
name: Download results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/bench-results
pattern: bench-results-*
merge-multiple: true
-
name: Download candidates
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/bench-results
pattern: "*-candidates"
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
-
name: Create metadata files
run: |
cp ./testconfig.yml /tmp/bench-results/
echo "$(date +'%Y%m%d-%H%M%S')" > /tmp/bench-results/name.txt
env|sort > /tmp/bench-results/env.txt
if [ -f "$GITHUB_EVENT_PATH" ]; then
cp $GITHUB_EVENT_PATH /tmp/bench-results/gha-event.json
fi
-
name: Generate HTML report
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
with:
targets: tests-gen
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.contexts.tests-results=cwd:///tmp/bench-results
*.output=./bin/report
env:
BAKE_ALLOW_REMOTE_FS_ACCESS: 1
-
name: Include results to report
run: |
if [[ -f ./bin/report/logs.tar.gz ]] && [[ -d /tmp/bench-results/logs ]]; then
rm -rf /tmp/bench-results/logs
fi
cp -r /tmp/bench-results/* ./bin/report/
-
name: Upload report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: report
path: ./bin/report
if-no-files-found: error
publish:
runs-on: ubuntu-24.04
needs:
- report
outputs:
pages_artifact_id: ${{ steps.upload-pages-artifact.outputs.artifact-id }}
steps:
-
name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
-
name: Download deployed results
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { exitCode } = await exec.getExecOutput('node', ['./website/downloadResults.js'], {
ignoreReturnCode: true,
});
if (exitCode !== 0) {
core.setFailed(`downloadResults.js failed with exit code ${exitCode}`);
}
-
name: Download report
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: report
path: /tmp/bench-report
-
name: Move reports
run: |
reportDir=$(cat /tmp/bench-report/name.txt)
rm -rf ./website/public/result/$reportDir
mkdir -p ./website/public/result/$reportDir
mv /tmp/bench-report/* ./website/public/result/$reportDir/
-
name: Garbage collect old results
run: |
node ./website/pruneResults.js
-
name: Build website
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
with:
source: .
no-cache: true
targets: website
provenance: false
-
name: Archive GitHub Pages artifact
run: |
tar --dereference --hard-dereference --directory ./bin/website -cvf "$RUNNER_TEMP/artifact.tar" .
-
name: Upload GitHub Pages artifact
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
id: upload-pages-artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error
deploy:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04
permissions:
pages: write
id-token: write
needs:
- publish
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
-
name: Deploy GitHub Pages site
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
cleanup-pages-artifact:
if: always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && needs.publish.result == 'success' && needs.deploy.result != 'skipped' && needs.publish.outputs.pages_artifact_id != ''
runs-on: ubuntu-24.04
permissions:
actions: write
needs:
- publish
- deploy
steps:
-
name: Delete GitHub Pages artifact
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
ARTIFACT_ID: ${{ needs.publish.outputs.pages_artifact_id }}
with:
script: |
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: Number(process.env.ARTIFACT_ID),
});