forked from moby/buildkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#3237 from crazy-max/ci-split-build-worklfow
ci: move frontend integration tests and build to a dedicated workflow
- Loading branch information
Showing
9 changed files
with
633 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# reusable workflow | ||
name: .test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
cache_scope: | ||
required: true | ||
type: string | ||
pkgs: | ||
required: true | ||
type: string | ||
kinds: | ||
required: true | ||
type: string | ||
tags: | ||
required: false | ||
type: string | ||
codecov_flags: | ||
required: false | ||
type: string | ||
includes: | ||
required: false | ||
type: string | ||
env: | ||
required: false | ||
type: string | ||
|
||
env: | ||
GO_VERSION: "1.19" | ||
SETUP_BUILDX_VERSION: "latest" | ||
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest" | ||
TESTFLAGS: "-v --parallel=6 --timeout=30m" | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
pkgs: ${{ steps.set.outputs.pkgs }} | ||
kinds: ${{ steps.set.outputs.kinds }} | ||
tags: ${{ steps.set.outputs.tags }} | ||
includes: ${{ steps.set.outputs.includes }} | ||
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.SETUP_BUILDX_VERSION }} | ||
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }} | ||
buildkitd-flags: --debug | ||
- | ||
name: Deps | ||
run: | | ||
npm install js-yaml | ||
- | ||
name: Set outputs | ||
id: set | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const yaml = require('js-yaml'); | ||
await core.group(`Set pkgs matrix`, async () => { | ||
const pkgs = `${{ inputs.pkgs }}`.trim().split(/\r?\n/); | ||
core.info(JSON.stringify(pkgs, null, 2)); | ||
core.setOutput('pkgs', JSON.stringify(pkgs)); | ||
}); | ||
await core.group(`Set kinds matrix`, async () => { | ||
const kinds = `${{ inputs.kinds }}`.trim().split(/\r?\n/); | ||
core.info(JSON.stringify(kinds, null, 2)); | ||
core.setOutput('kinds', JSON.stringify(kinds)); | ||
}); | ||
await core.group(`Set tags matrix`, async () => { | ||
const tags = `${{ inputs.tags }}`.trim().split(/\r?\n/); | ||
core.info(JSON.stringify(tags, null, 2)); | ||
core.setOutput('tags', JSON.stringify(tags)); | ||
}); | ||
await core.group(`Set includes`, async () => { | ||
const includes = yaml.load(`${{ inputs.includes }}`.trim()); | ||
core.info(JSON.stringify(includes, null, 2)); | ||
core.setOutput('includes', JSON.stringify(includes ?? [])); | ||
}); | ||
- | ||
name: Build | ||
run: | | ||
./hack/build_ci_first_pass integration-tests | ||
env: | ||
CACHE_FROM: type=gha,scope=${{ inputs.cache_scope }} | ||
CACHE_TO: type=gha,scope=${{ inputs.cache_scope }} | ||
|
||
run: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
pkg: ${{ fromJson(needs.prepare.outputs.pkgs) }} | ||
kind: ${{ fromJson(needs.prepare.outputs.kinds) }} | ||
tags: ${{ fromJson(needs.prepare.outputs.tags) }} | ||
include: ${{ fromJson(needs.prepare.outputs.includes) }} | ||
worker: | ||
- containerd | ||
- containerd-rootless | ||
- containerd-1.6 | ||
- containerd-snapshotter-stargz | ||
- oci | ||
- oci-rootless | ||
- oci-snapshotter-stargz | ||
steps: | ||
- | ||
name: Environment variables | ||
run: | | ||
for l in "${{ inputs.env }}"; do | ||
echo "${l?}" >> $GITHUB_ENV | ||
done | ||
- | ||
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.SETUP_BUILDX_VERSION }} | ||
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }} | ||
buildkitd-flags: --debug | ||
- | ||
name: Test | ||
continue-on-error: ${{ matrix.tags == 'nydus' }} | ||
run: | | ||
if [ -n "${{ matrix.tags }}" ]; then | ||
TESTFLAGS="${TESTFLAGS} --tags=${{ matrix.tags }}" | ||
export BUILDKITD_TAGS="${{ matrix.tags }}" | ||
fi | ||
if [ -n "${{ matrix.worker }}" ]; then | ||
export TESTFLAGS="${TESTFLAGS} --run=//worker=${{ matrix.worker }}$" | ||
fi | ||
./hack/test ${{ matrix.kind }} | ||
mv ./coverage/coverage.txt ./coverage/coverage-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.kind }}-${{ matrix.worker }}-${{ matrix.tags }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]').txt | ||
env: | ||
TEST_COVERAGE: 1 | ||
TESTPKGS: ${{ matrix.pkg }} | ||
SKIP_INTEGRATION_TESTS: ${{ matrix.skip-integration-tests }} | ||
CACHE_FROM: type=gha,scope=${{ inputs.cache_scope }} | ||
- | ||
name: Upload coverage file | ||
continue-on-error: ${{ matrix.tags == 'nydus' }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage | ||
path: ./coverage | ||
|
||
upload-coverage: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- run | ||
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 | ||
id: files | ||
uses: actions/github-script@v6 | ||
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@v3 | ||
with: | ||
files: ${{ steps.files.outputs.result }} | ||
flags: ${{ matrix.codecov_flags }} |
Oops, something went wrong.