diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b1d03c777433..510e40d9d58cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,18 +6,14 @@ concurrency: on: schedule: - - cron: '0 10 * * *' # everyday at 10am + - cron: '0 10 * * *' workflow_dispatch: push: branches: - 'master' tags: - 'v*' - - 'dockerfile/*' pull_request: - branches: - - 'master' - - 'v*' paths-ignore: - 'README.md' - 'docs/**' @@ -26,9 +22,8 @@ on: env: REPO_SLUG_ORIGIN: "moby/buildkit:latest" REPO_SLUG_TARGET: "moby/buildkit" - DF_REPO_SLUG_TARGET: "docker/dockerfile-upstream" PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64" - CACHE_GHA_SCOPE_IT: "integration-tests" + CACHE_GHA_SCOPE_IT: "build-integration-tests" CACHE_GHA_SCOPE_BINARIES: "binaries" CACHE_GHA_SCOPE_CROSS: "cross" TESTFLAGS: "-v --parallel=6 --timeout=30m" @@ -72,13 +67,13 @@ jobs: test: runs-on: ubuntu-20.04 - needs: [base] + needs: + - base strategy: fail-fast: false matrix: pkg: - ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend - - ./frontend/dockerfile worker: - containerd - containerd-rootless @@ -90,10 +85,6 @@ jobs: - oci-snapshotter-stargz typ: - integration - - dockerfile - exclude: - - pkg: ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend - typ: dockerfile include: - pkg: ./... skip-integration-tests: 1 @@ -127,7 +118,7 @@ jobs: TEST_COVERAGE: 1 TESTPKGS: ${{ matrix.pkg }} SKIP_INTEGRATION_TESTS: ${{ matrix.skip-integration-tests }} - CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} + CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} - name: Upload coverage file uses: actions/upload-artifact@v3 @@ -222,7 +213,9 @@ jobs: upload-coverage: runs-on: ubuntu-20.04 - needs: [test, test-os] + needs: + - test + - test-os steps: - name: Checkout @@ -305,7 +298,10 @@ jobs: image: runs-on: ubuntu-20.04 - needs: [release-base, test, cross] + needs: + - release-base + - test + - cross strategy: fail-fast: false matrix: @@ -347,7 +343,10 @@ jobs: binaries: runs-on: ubuntu-20.04 - needs: [release-base, test, cross] + needs: + - release-base + - test + - cross steps: - name: Checkout @@ -393,74 +392,3 @@ jobs: draft: true files: ./release-out/* name: ${{ needs.release-base.outputs.tag }} - - frontend-base: - runs-on: ubuntu-20.04 - if: github.event_name != 'schedule' - outputs: - typ: ${{ steps.prep.outputs.typ }} - tag: ${{ steps.prep.outputs.tag }} - push: ${{ steps.prep.outputs.push }} - steps: - - - name: Prepare - id: prep - run: | - TYP=master - TAG=mainline - PUSH=false - if [[ $GITHUB_REF == refs/tags/dockerfile/* ]]; then - TYP=tag - TAG=${GITHUB_REF#refs/tags/} - PUSH=push - elif [[ $GITHUB_REF == refs/heads/* ]]; then - PUSH=push - fi - echo "typ=${TYP}" >>${GITHUB_OUTPUT} - echo "tag=${TAG}" >>${GITHUB_OUTPUT} - echo "push=${PUSH}" >>${GITHUB_OUTPUT} - - frontend-image: - runs-on: ubuntu-20.04 - if: github.event_name != 'schedule' - needs: [frontend-base, test] - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - with: - version: ${{ env.BUILDX_VERSION }} - driver-opts: image=${{ env.REPO_SLUG_ORIGIN }} - buildkitd-flags: --debug - - - name: Login to DockerHub - uses: docker/login-action@v2 - if: needs.frontend-base.outputs.push == 'push' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build ${{ needs.frontend-base.outputs.typ }}/${{ needs.frontend-base.outputs.tag }} - run: | - ./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" "${{ needs.frontend-base.outputs.tag }}" "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}" - env: - PLATFORMS: ${{ env.PLATFORMS }},linux/mips,linux/mipsle,linux/mips64,linux/mips64le - CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }} - CACHE_TO: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }} - - - name: Build ${{ needs.frontend-base.outputs.typ }}/labs - if: needs.frontend-base.outputs.typ == 'master' - run: | - ./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" labs "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}" - env: - PLATFORMS: ${{ env.PLATFORMS }},linux/mips,linux/mipsle,linux/mips64,linux/mips64le - CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }} diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000000000..ef2408a5f84b9 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,203 @@ +name: frontend + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + push: + branches: + - 'master' + tags: + - 'dockerfile/*' + pull_request: + paths-ignore: + - 'README.md' + - 'docs/**' + - 'frontend/dockerfile/docs/**' + +env: + REPO_SLUG_ORIGIN: "moby/buildkit:latest" + REPO_SLUG_TARGET: "docker/dockerfile-upstream" + PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/mips,linux/mipsle,linux/mips64,linux/mips64le,linux/s390x,linux/ppc64le,linux/riscv64" + CACHE_GHA_SCOPE_IT: "frontend-integration-tests" + TESTFLAGS: "-v --parallel=6 --timeout=30m" + BUILDX_VERSION: "v0.9.1" # leave empty to use the one available on GitHub virtual environment + +jobs: + base: + runs-on: ubuntu-20.04 + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + version: ${{ env.BUILDX_VERSION }} + driver-opts: image=${{ env.REPO_SLUG_ORIGIN }} + buildkitd-flags: --debug + - + name: Build ${{ env.CACHE_GHA_SCOPE_IT }} + run: | + ./hack/build_ci_first_pass integration-tests + env: + CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} + CACHE_TO: type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} + + test: + runs-on: ubuntu-20.04 + needs: + - base + strategy: + fail-fast: false + matrix: + pkg: + - ./frontend/dockerfile + worker: + - containerd + - containerd-rootless + - containerd-1.5 + - containerd-1.4 + - containerd-snapshotter-stargz + - oci + - oci-rootless + - oci-snapshotter-stargz + typ: + - integration + - dockerfile + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + version: ${{ env.BUILDX_VERSION }} + driver-opts: image=${{ env.REPO_SLUG_ORIGIN }} + buildkitd-flags: --debug + - + name: Test pkg=${{ matrix.pkg }} ; typ=${{ matrix.typ }} ; worker=${{ matrix.worker }} + run: | + if [ -n "${{ matrix.worker }}" ]; then + export TESTFLAGS="${TESTFLAGS} --run=//worker=${{ matrix.worker }}$" + fi + ./hack/test ${{ matrix.typ }} + mv ./coverage/coverage.txt ./coverage/coverage-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.typ }}-${{ matrix.worker }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]').txt + env: + TEST_COVERAGE: 1 + TESTPKGS: ${{ matrix.pkg }} + CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} + - + name: Upload coverage file + uses: actions/upload-artifact@v3 + with: + name: coverage + path: ./coverage + + upload-coverage: + runs-on: ubuntu-20.04 + needs: + - test + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Download coverage files + uses: actions/download-artifact@v3 + with: + name: coverage + path: ./coverage + - + name: List coverage files + uses: actions/github-script@v6 + id: files + with: + result-encoding: string + script: | + return require('fs').readdirSync('./coverage', {withFileTypes: true}) + .filter(item => !item.isDirectory()) + .map(item => `./coverage/${item.name}`) + .join(','); + - + name: Send to Codecov + uses: codecov/codecov-action@v2 + with: + files: ${{ steps.files.outputs.result }} + + image: + runs-on: ubuntu-20.04 + needs: + - test + steps: + - + name: Prepare + run: | + TYP=master + TAG=mainline + PUSH=false + if [[ $GITHUB_REF == refs/tags/dockerfile/* ]]; then + TYP=tag + TAG=${GITHUB_REF#refs/tags/} + PUSH=push + elif [[ $GITHUB_REF == refs/heads/* ]]; then + PUSH=push + fi + echo "TYP=${TYP}" >> $GITHUB_ENV + echo "TAG=${TAG}" >> $GITHUB_ENV + echo "PUSH=${PUSH}" >> $GITHUB_ENV + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + version: ${{ env.BUILDX_VERSION }} + driver-opts: image=${{ env.REPO_SLUG_ORIGIN }} + buildkitd-flags: --debug + - + name: Login to DockerHub + uses: docker/login-action@v2 + if: env.PUSH == 'push' + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build ${{ env.TYP }}/${{ env.TAG }} + run: | + ./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ env.TYP }}" "${{ env.TAG }}" "$REPO_SLUG_TARGET" "${{ env.PUSH }}" + env: + CACHE_FROM: type=gha,scope=frontend-${{ env.TYP }} + CACHE_TO: type=gha,scope=frontend-${{ env.TYP }} + - + name: Build ${{ env.TYP }}/labs + if: env.TYP == 'master' + run: | + ./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ env.TYP }}" labs "$REPO_SLUG_TARGET" "${{ env.PUSH }}" + env: + CACHE_FROM: type=gha,scope=frontend-${{ env.TYP }}