|
1 |
| -name: Continuous integration |
| 1 | +name: ci |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
2 | 6 |
|
3 | 7 | on:
|
4 | 8 | push:
|
5 | 9 | branches:
|
6 |
| - - v2 |
| 10 | + - 'v2' |
| 11 | + tags: |
| 12 | + - 'v*' |
7 | 13 | pull_request:
|
8 | 14 | workflow_dispatch:
|
9 | 15 | inputs:
|
10 | 16 | debug_enabled:
|
11 | 17 | description: 'To run with tmate enter "debug_enabled"'
|
12 | 18 | required: false
|
13 | 19 | default: "false"
|
| 20 | + |
14 | 21 | env:
|
15 |
| - GO_VERSION: 1.18.5 |
16 |
| - DOCKER_CLI_VERSION: 20.10.17 |
| 22 | + GO_VERSION: "1.18.5" # for non sandboxed e2e tests |
| 23 | + DESTDIR: "./bin" |
| 24 | + DOCKER_CLI_VERSION: "20.10.17" |
| 25 | + |
17 | 26 | jobs:
|
18 |
| - lint: |
19 |
| - name: Lint |
| 27 | + prepare: |
20 | 28 | runs-on: ubuntu-latest
|
| 29 | + outputs: |
| 30 | + matrix: ${{ steps.platforms.outputs.matrix }} |
21 | 31 | steps:
|
22 |
| - - name: Checkout code into the Go module directory |
| 32 | + - |
| 33 | + name: Checkout |
23 | 34 | uses: actions/checkout@v3
|
| 35 | + - |
| 36 | + name: Create matrix |
| 37 | + id: platforms |
| 38 | + run: | |
| 39 | + echo ::set-output name=matrix::$(docker buildx bake binary-cross --print | jq -cr '.target."binary-cross".platforms') |
| 40 | + - |
| 41 | + name: Show matrix |
| 42 | + run: | |
| 43 | + echo ${{ steps.platforms.outputs.matrix }} |
24 | 44 |
|
25 |
| - - name: Set up Go ${{ env.GO_VERSION }} |
26 |
| - uses: actions/setup-go@v3 |
27 |
| - with: |
28 |
| - go-version: ${{ env.GO_VERSION }} |
29 |
| - cache: true |
30 |
| - |
31 |
| - - name: Validate go-mod, license headers and docs are up-to-date |
32 |
| - run: make validate |
33 |
| - |
34 |
| - - name: Run golangci-lint |
35 |
| - env: |
36 |
| - BUILD_TAGS: e2e |
37 |
| - uses: golangci/golangci-lint-action@v3 |
38 |
| - with: |
39 |
| - version: v1.47.3 |
40 |
| - args: --timeout=180s |
41 |
| - |
42 |
| - # only on main branch, costs too much for the gain on every PR |
43 |
| - validate-cross-build: |
44 |
| - name: Validate cross build |
| 45 | + validate: |
45 | 46 | runs-on: ubuntu-latest
|
46 |
| - if: github.ref == 'refs/heads/main' |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + target: |
| 51 | + - lint |
| 52 | + - validate-go-mod |
| 53 | + - validate-headers |
| 54 | + - validate-docs |
47 | 55 | steps:
|
48 |
| - - name: Checkout code into the Go module directory |
| 56 | + - |
| 57 | + name: Checkout |
49 | 58 | uses: actions/checkout@v3
|
| 59 | + - |
| 60 | + name: Set up Docker Buildx |
| 61 | + uses: docker/setup-buildx-action@v2 |
| 62 | + - |
| 63 | + name: Run |
| 64 | + run: | |
| 65 | + make ${{ matrix.target }} |
50 | 66 |
|
51 |
| - - name: Set up Go ${{ env.GO_VERSION }} |
52 |
| - uses: actions/setup-go@v3 |
| 67 | + binary: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: |
| 70 | + - prepare |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + platform: ${{ fromJson(needs.prepare.outputs.matrix) }} |
| 75 | + steps: |
| 76 | + - |
| 77 | + name: Prepare |
| 78 | + run: | |
| 79 | + platform=${{ matrix.platform }} |
| 80 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 81 | + - |
| 82 | + name: Checkout |
| 83 | + uses: actions/checkout@v3 |
| 84 | + - |
| 85 | + name: Set up QEMU |
| 86 | + uses: docker/setup-qemu-action@v2 |
| 87 | + - |
| 88 | + name: Set up Docker Buildx |
| 89 | + uses: docker/setup-buildx-action@v2 |
| 90 | + - |
| 91 | + name: Build |
| 92 | + uses: docker/bake-action@v2 |
53 | 93 | with:
|
54 |
| - go-version: ${{ env.GO_VERSION }} |
55 |
| - cache: true |
56 |
| - |
57 |
| - # Ensure we don't discover cross platform build issues at release time. |
58 |
| - # Time used to build linux here is gained back in the build for local E2E step |
59 |
| - - name: Build packages |
60 |
| - run: make -f builder.Makefile cross |
| 94 | + targets: release |
| 95 | + set: | |
| 96 | + *.platform=${{ matrix.platform }} |
| 97 | + *.cache-from=type=gha,scope=binary-${{ env.PLATFORM_PAIR }} |
| 98 | + *.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max |
| 99 | + - |
| 100 | + name: Upload artifacts |
| 101 | + uses: actions/upload-artifact@v3 |
| 102 | + with: |
| 103 | + name: compose |
| 104 | + path: ${{ env.DESTDIR }}/* |
| 105 | + if-no-files-found: error |
61 | 106 |
|
62 |
| - build-plugin: |
63 |
| - name: Build and tests in plugin mode |
| 107 | + test: |
64 | 108 | runs-on: ubuntu-latest
|
65 | 109 | steps:
|
66 |
| - - name: Checkout code into the Go module directory |
| 110 | + - |
| 111 | + name: Checkout |
67 | 112 | uses: actions/checkout@v3
|
68 |
| - |
69 |
| - - name: Set up Go ${{ env.GO_VERSION }} |
70 |
| - uses: actions/setup-go@v3 |
| 113 | + - |
| 114 | + name: Set up Docker Buildx |
| 115 | + uses: docker/setup-buildx-action@v2 |
| 116 | + - |
| 117 | + name: Test |
| 118 | + uses: docker/bake-action@v2 |
71 | 119 | with:
|
72 |
| - go-version: ${{ env.GO_VERSION }} |
73 |
| - cache: true |
74 |
| - |
75 |
| - - name: Setup docker CLI |
76 |
| - run: | |
77 |
| - curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz |
78 |
| - sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version |
79 |
| -
|
80 |
| - - name: Test |
81 |
| - run: make -f builder.Makefile test |
82 |
| - |
83 |
| - - name: Build for local E2E |
84 |
| - env: |
85 |
| - BUILD_TAGS: e2e |
86 |
| - run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin |
| 120 | + targets: test |
| 121 | + set: | |
| 122 | + *.cache-from=type=gha,scope=test |
| 123 | + *.cache-to=type=gha,scope=test |
87 | 124 |
|
88 |
| - - name: E2E Test in plugin mode |
89 |
| - run: make e2e-compose |
90 |
| - |
91 |
| - build-standalone: |
92 |
| - name: Build and tests in standalone mode |
| 125 | + e2e: |
93 | 126 | runs-on: ubuntu-latest
|
| 127 | + env: |
| 128 | + DESTDIR: "./bin/build" |
| 129 | + strategy: |
| 130 | + fail-fast: false |
| 131 | + matrix: |
| 132 | + mode: |
| 133 | + - plugin |
| 134 | + - standalone |
94 | 135 | steps:
|
95 |
| - - name: Checkout code into the Go module directory |
| 136 | + - |
| 137 | + name: Checkout |
96 | 138 | uses: actions/checkout@v3
|
97 |
| - |
98 |
| - - name: Set up Go ${{ env.GO_VERSION }} |
| 139 | + - |
| 140 | + name: Set up Docker Buildx |
| 141 | + uses: docker/setup-buildx-action@v2 |
| 142 | + - |
| 143 | + name: Set up Go |
99 | 144 | uses: actions/setup-go@v3
|
100 | 145 | with:
|
101 | 146 | go-version: ${{ env.GO_VERSION }}
|
102 | 147 | cache: true
|
103 |
| - |
104 |
| - - name: Setup docker CLI |
| 148 | + - |
| 149 | + name: Setup docker CLI |
105 | 150 | run: |
|
106 | 151 | curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz
|
107 | 152 | sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
|
108 |
| -
|
109 |
| - - name: Build for local E2E |
| 153 | + - |
| 154 | + name: Build |
| 155 | + uses: docker/bake-action@v2 |
| 156 | + with: |
| 157 | + targets: binary |
| 158 | + set: | |
| 159 | + *.cache-from=type=gha,scope=binary-linux-amd64 |
| 160 | + *.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }} |
| 161 | + *.cache-to=type=gha,scope=binary-e2e-${{ matrix.mode }},mode=max |
110 | 162 | env:
|
111 | 163 | BUILD_TAGS: e2e
|
112 |
| - run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin |
113 |
| - |
114 |
| - - name: Setup tmate session |
115 |
| - uses: mxschmitt/action-tmate@v3 |
| 164 | + - |
| 165 | + name: Setup tmate session |
| 166 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} |
| 167 | + uses: mxschmitt/action-tmate@8b4e4ac71822ed7e0ad5fb3d1c33483e9e8fb270 # v3.11 |
116 | 168 | with:
|
117 | 169 | limit-access-to-actor: true
|
118 | 170 | github-token: ${{ secrets.GITHUB_TOKEN }}
|
119 |
| - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} |
120 |
| - |
121 |
| - - name: E2E Test in standalone mode |
| 171 | + - |
| 172 | + name: Test plugin mode |
| 173 | + if: ${{ matrix.mode == 'plugin' }} |
| 174 | + run: | |
| 175 | + make e2e-compose |
| 176 | + - |
| 177 | + name: Test standalone mode |
| 178 | + if: ${{ matrix.mode == 'standalone' }} |
122 | 179 | run: |
|
123 | 180 | rm -f /usr/local/bin/docker-compose
|
124 |
| - cp bin/docker-compose /usr/local/bin |
| 181 | + cp bin/build/docker-compose /usr/local/bin |
125 | 182 | make e2e-compose-standalone
|
| 183 | +
|
| 184 | + release: |
| 185 | + runs-on: ubuntu-latest |
| 186 | + needs: |
| 187 | + - binary |
| 188 | + steps: |
| 189 | + - |
| 190 | + name: Checkout |
| 191 | + uses: actions/checkout@v3 |
| 192 | + - |
| 193 | + name: Download artifacts |
| 194 | + uses: actions/download-artifact@v3 |
| 195 | + with: |
| 196 | + name: compose |
| 197 | + path: ${{ env.DESTDIR }} |
| 198 | + - |
| 199 | + name: License |
| 200 | + run: cp packaging/* ${{ env.DESTDIR }}/ |
| 201 | + - |
| 202 | + name: List artifacts |
| 203 | + run: | |
| 204 | + tree -nh ${{ env.DESTDIR }} |
| 205 | + - |
| 206 | + name: Check artifacts |
| 207 | + run: | |
| 208 | + find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} + |
| 209 | + - |
| 210 | + name: GitHub Release |
| 211 | + if: startsWith(github.ref, 'refs/tags/v') |
| 212 | + uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0 |
| 213 | + with: |
| 214 | + artifacts: ${{ env.DESTDIR }}/* |
| 215 | + generateReleaseNotes: true |
| 216 | + draft: true |
| 217 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments