Merge pull request #511 from docker/bot/undock-releases-json #1510
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
name: test | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
paths-ignore: | |
- '.github/*-releases.json' | |
env: | |
NODE_VERSION: "20" | |
BUILDX_VERSION: "v0.18.0" | |
BUILDKIT_IMAGE: "moby/buildkit:v0.17.2" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node_version: | |
- 20 | |
- 18 | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Test | |
uses: docker/bake-action@v5 | |
with: | |
targets: test-coverage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_VERSION: ${{ matrix.node_version }} | |
- | |
name: Check coverage | |
run: | | |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then | |
echo "RUN_CODECOV=true" >> $GITHUB_ENV | |
else | |
echo "RUN_CODECOV=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- | |
name: Upload coverage | |
uses: codecov/codecov-action@v5 | |
if: env.RUN_CODECOV == 'true' && matrix.node_version == env.NODE_VERSION | |
with: | |
files: ./coverage/clover.xml | |
flags: unit | |
token: ${{ secrets.CODECOV_TOKEN }} | |
prepare-itg: | |
runs-on: ubuntu-latest | |
outputs: | |
includes: ${{ steps.set.outputs.includes }} | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Enable corepack | |
run: | | |
corepack enable | |
yarn --version | |
- | |
name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- | |
name: Install | |
run: yarn install | |
- | |
name: Create includes | |
id: set | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let tests = []; | |
await core.group(`Get tests`, async () => { | |
const res = await exec.getExecOutput('yarn', ['run', 'test:itg-list'], { | |
silent: true, | |
ignoreReturnCode: true | |
}); | |
if (res.stderr.length > 0 && res.exitCode != 0) { | |
throw new Error(res.stderr); | |
} | |
for (const test of res.stdout.trim().split('\n')) { | |
tests.push(test.replace(/^.*__tests__\//, '')); | |
} | |
core.info(`tests: ${JSON.stringify(tests)}`); | |
}); | |
await core.group(`Set includes`, async () => { | |
let includes = []; | |
for (const os of ['ubuntu-latest', 'macos-13', 'windows-latest']) { | |
for (const test of tests) { | |
if (os === 'macos-13' && test === 'docker/install.test.itg.ts') { | |
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: '27.3.1' }); | |
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'master' }); | |
includes.push({ os: os, test: test, docker_install_type: 'image', docker_install_version: 'latest' }); | |
includes.push({ os: os, test: test, docker_install_type: 'archive', docker_install_version: 'v26.1.4' }); | |
includes.push({ os: os, test: test, docker_install_type: 'archive', docker_install_version: 'latest' }); | |
} else { | |
includes.push({ os: os, test: test }); | |
} | |
} | |
} | |
core.info(`includes: ${JSON.stringify(includes)}`); | |
core.setOutput('includes', JSON.stringify(includes)); | |
}); | |
- | |
name: Show matrix | |
run: | | |
echo ${{ steps.tests.outputs.matrix }} | |
test-itg: | |
runs-on: ${{ matrix.os }} | |
needs: | |
- prepare-itg | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.prepare-itg.outputs.includes) }} | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Expose GitHub Runtime | |
uses: crazy-max/ghaction-github-runtime@v3 | |
- | |
# FIXME: Needs to setup node twice on Windows due to a bug with runner | |
name: Setup Node | |
if: startsWith(matrix.os, 'windows') | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- | |
name: Enable corepack | |
run: | | |
corepack enable | |
yarn --version | |
- | |
name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'yarn' | |
- | |
name: Set up Docker Buildx | |
if: startsWith(matrix.os, 'ubuntu') | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: ${{ env.BUILDX_VERSION }} | |
driver: docker | |
- | |
name: Set up container builder | |
if: startsWith(matrix.os, 'ubuntu') | |
id: builder | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: ${{ env.BUILDX_VERSION }} | |
driver-opts: image=${{ env.BUILDKIT_IMAGE }} | |
use: false | |
- | |
name: Install | |
run: yarn install | |
- | |
name: Test | |
run: | | |
yarn test:itg-coverage --runTestsByPath __tests__/${{ matrix.test }} --coverageDirectory=./coverage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }} | |
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }} | |
DOCKER_INSTALL_TYPE: ${{ matrix.docker_install_type }} | |
DOCKER_INSTALL_VERSION: ${{ matrix.docker_install_version }} | |
- | |
name: Check coverage | |
run: | | |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then | |
echo "RUN_CODECOV=true" >> $GITHUB_ENV | |
else | |
echo "RUN_CODECOV=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- | |
name: Upload coverage | |
uses: codecov/codecov-action@v5 | |
if: env.RUN_CODECOV == 'true' | |
with: | |
files: ./coverage/clover.xml | |
flags: itg | |
token: ${{ secrets.CODECOV_TOKEN }} |