forked from docker/compose
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better sandboxed workflow and enhanced cross compilation
Signed-off-by: CrazyMax <[email protected]>
- Loading branch information
Showing
18 changed files
with
478 additions
and
481 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
bin/ | ||
dist/ |
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 |
---|---|---|
@@ -1,125 +1,217 @@ | ||
name: Continuous integration | ||
name: ci | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- v2 | ||
- 'v2' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
workflow_dispatch: | ||
inputs: | ||
debug_enabled: | ||
description: 'To run with tmate enter "debug_enabled"' | ||
required: false | ||
default: "false" | ||
|
||
env: | ||
GO_VERSION: 1.18.5 | ||
DOCKER_CLI_VERSION: 20.10.17 | ||
GO_VERSION: "1.18.5" # for non sandboxed e2e tests | ||
DESTDIR: "./bin" | ||
DOCKER_CLI_VERSION: "20.10.17" | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.platforms.outputs.matrix }} | ||
steps: | ||
- name: Checkout code into the Go module directory | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Create matrix | ||
id: platforms | ||
run: | | ||
echo ::set-output name=matrix::$(docker buildx bake binary-cross --print | jq -cr '.target."binary-cross".platforms') | ||
- | ||
name: Show matrix | ||
run: | | ||
echo ${{ steps.platforms.outputs.matrix }} | ||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: true | ||
|
||
- name: Validate go-mod, license headers and docs are up-to-date | ||
run: make validate | ||
|
||
- name: Run golangci-lint | ||
env: | ||
BUILD_TAGS: e2e | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.47.3 | ||
args: --timeout=180s | ||
|
||
# only on main branch, costs too much for the gain on every PR | ||
validate-cross-build: | ||
name: Validate cross build | ||
validate: | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- lint | ||
- validate-go-mod | ||
- validate-headers | ||
- validate-docs | ||
steps: | ||
- name: Checkout code into the Go module directory | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Run | ||
run: | | ||
make ${{ matrix.target }} | ||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v3 | ||
binary: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: ${{ fromJson(needs.prepare.outputs.matrix) }} | ||
steps: | ||
- | ||
name: Prepare | ||
run: | | ||
platform=${{ matrix.platform }} | ||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Build | ||
uses: docker/bake-action@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: true | ||
|
||
# Ensure we don't discover cross platform build issues at release time. | ||
# Time used to build linux here is gained back in the build for local E2E step | ||
- name: Build packages | ||
run: make -f builder.Makefile cross | ||
targets: release | ||
set: | | ||
*.platform=${{ matrix.platform }} | ||
*.cache-from=type=gha,scope=binary-${{ env.PLATFORM_PAIR }} | ||
*.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max | ||
- | ||
name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: compose | ||
path: ${{ env.DESTDIR }}/* | ||
if-no-files-found: error | ||
|
||
build-plugin: | ||
name: Build and tests in plugin mode | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code into the Go module directory | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Test | ||
uses: docker/bake-action@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: true | ||
|
||
- name: Setup docker CLI | ||
run: | | ||
curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz | ||
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version | ||
- name: Test | ||
run: make -f builder.Makefile test | ||
|
||
- name: Build for local E2E | ||
env: | ||
BUILD_TAGS: e2e | ||
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin | ||
targets: test | ||
set: | | ||
*.cache-from=type=gha,scope=test | ||
*.cache-to=type=gha,scope=test | ||
- name: E2E Test in plugin mode | ||
run: make e2e-compose | ||
|
||
build-standalone: | ||
name: Build and tests in standalone mode | ||
e2e: | ||
runs-on: ubuntu-latest | ||
env: | ||
DESTDIR: "./bin/build" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
mode: | ||
- plugin | ||
- standalone | ||
steps: | ||
- name: Checkout code into the Go module directory | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go ${{ env.GO_VERSION }} | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: true | ||
|
||
- name: Setup docker CLI | ||
- | ||
name: Setup docker CLI | ||
run: | | ||
curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz | ||
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version | ||
- name: Build for local E2E | ||
- | ||
name: Build | ||
uses: docker/bake-action@v2 | ||
with: | ||
targets: binary | ||
set: | | ||
*.cache-from=type=gha,scope=binary-linux-amd64 | ||
*.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }} | ||
*.cache-to=type=gha,scope=binary-e2e-${{ matrix.mode }},mode=max | ||
env: | ||
BUILD_TAGS: e2e | ||
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin | ||
|
||
- name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
- | ||
name: Setup tmate session | ||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} | ||
uses: mxschmitt/action-tmate@8b4e4ac71822ed7e0ad5fb3d1c33483e9e8fb270 # v3.11 | ||
with: | ||
limit-access-to-actor: true | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} | ||
|
||
- name: E2E Test in standalone mode | ||
- | ||
name: Test plugin mode | ||
if: ${{ matrix.mode == 'plugin' }} | ||
run: | | ||
make e2e-compose | ||
- | ||
name: Test standalone mode | ||
if: ${{ matrix.mode == 'standalone' }} | ||
run: | | ||
rm -f /usr/local/bin/docker-compose | ||
cp bin/docker-compose /usr/local/bin | ||
cp bin/build/docker-compose /usr/local/bin | ||
make e2e-compose-standalone | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- binary | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: compose | ||
path: ${{ env.DESTDIR }} | ||
- | ||
name: License | ||
run: cp packaging/* ${{ env.DESTDIR }}/ | ||
- | ||
name: List artifacts | ||
run: | | ||
tree -nh ${{ env.DESTDIR }} | ||
- | ||
name: Check artifacts | ||
run: | | ||
find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} + | ||
- | ||
name: GitHub Release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0 | ||
with: | ||
artifacts: ${{ env.DESTDIR }}/* | ||
generateReleaseNotes: true | ||
draft: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
bin/ | ||
dist/ | ||
/.vscode/ |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
run: | ||
concurrency: 2 | ||
timeout: 10m | ||
linters: | ||
enable-all: false | ||
disable-all: true | ||
|
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
Oops, something went wrong.