-
-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (146 loc) · 6.5 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
node-versions: "['18.x', '20.x', '22.x']"
os-variants: "['ubuntu-latest', 'macos-13', 'windows-latest']"
docker-engine-connection-variants: "['ssh', 'http', 'https', 'socket']"
platform-variants: "['node', 'bun', 'deno', 'node-undici', 'bun-undici', 'deno-undici']"
docker-engine-versions: "['docker.io/library/docker:19-dind', 'docker.io/library/docker:20-dind', 'docker.io/library/docker:23-dind', 'docker.io/library/docker:24-dind', 'docker.io/library/docker:25-dind', 'docker.io/library/docker:26-dind', 'docker.io/library/docker:27-dind', 'docker.io/library/docker:dind']"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Yes this job is really needed as you can't access the global env var outside of a job step
# and I want to use those global env vars to setup things like the matricies for other jobs.
compute-matricies:
runs-on: ubuntu-latest
outputs:
os-variants: ${{ steps.compute-matricies.outputs.os-variants }}
node-versions: ${{ steps.compute-matricies.outputs.node-versions }}
platform-variants: ${{ steps.compute-matricies.outputs.platform-variants }}
docker-engine-versions: ${{ steps.compute-matricies.outputs.docker-engine-versions }}
docker-engine-connection-variants: ${{ steps.compute-matricies.outputs.docker-engine-connection-variants }}
steps:
- id: compute-matricies
run: |
echo "os-variants=${{ env.os-variants }}" >> $GITHUB_OUTPUT
echo "node-versions=${{ env.node-versions }}" >> $GITHUB_OUTPUT
echo "platform-variants=${{ env.platform-variants }}" >> $GITHUB_OUTPUT
echo "docker-engine-versions=${{ env.docker-engine-versions }}" >> $GITHUB_OUTPUT
echo "docker-engine-connection-variants=${{ env.docker-engine-connection-variants }}" >> $GITHUB_OUTPUT
# Creates pnpm caches for all os/node-version combinations
update-pnpm-caches:
runs-on: ${{ matrix.os }}
needs: [compute-matricies]
defaults:
run:
shell: bash
strategy:
matrix:
os: ${{ fromJSON(needs.compute-matricies.outputs.os-variants) }}
node-version: ${{ fromJSON(needs.compute-matricies.outputs.node-versions) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/common-setup
with:
node-version: ${{ matrix.node-version }}
# Builds and lints the typescript code
typescript-build:
runs-on: ubuntu-latest
needs: [update-pnpm-caches]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/common-setup
with:
node-version: 18.x
# - run: pnpm check
# - run: pnpm build
# - run: pnpm lint
# Publishes the docker images to ghcr.io (only if they have been modified in this push/pull_request)
docker-build:
runs-on: ubuntu-latest
needs: [compute-matricies]
strategy:
matrix:
dockerfile: ${{ fromJSON(needs.compute-matricies.outputs.docker-engine-connection-variants) }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.dockerfile }}-dind
- uses: docker/build-push-action@v6
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/dind-${{ matrix.dockerfile }}.dockerfile
build-args: DIND_BASE_IMAGE=docker.io/library/docker:dind
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
docker-engine-tests:
needs: [compute-matricies, typescript-build, docker-build]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os: ${{ fromJSON(needs.compute-matricies.outputs.os-variants) }}
node-version: ${{ fromJSON(needs.compute-matricies.outputs.node-versions) }}
platform-variant: ${{ fromJSON(needs.compute-matricies.outputs.platform-variants) }}
steps:
- uses: actions/checkout@v4
- uses: douglascamata/setup-docker-macos-action@v1-alpha.13
if: startsWith(matrix.os, 'macos')
- uses: ./.github/actions/windows-wsl2
if: startsWith(matrix.os, 'windows')
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/common-setup
with:
node-version: ${{ matrix.node-version }}
- run: |
docker_engine_versions=$(echo ${{ needs.compute-matricies.outputs.docker-engine-versions }} | tr -d "[]" | tr -d "'")
IFS=',' read -r -a docker_engine_versions_array <<< "$docker_engine_versions"
docker_engine_connection_variants=$(echo ${{ needs.compute-matricies.outputs.docker-engine-connection-variants }} | tr -d "[]" | tr -d "'")
IFS=',' read -r -a docker_engine_connection_variants_array <<< "$docker_engine_connection_variants"
for image in "${docker_engine_versions_array[@]}"; do
image=$(echo $image | xargs)
docker pull $image
done
for docker_engine_version in "${docker_engine_versions_array[@]}"; do
for docker_engine_connection_variant in "${docker_engine_connection_variants_array[@]}"; do
conn_variant=$(echo $docker_engine_connection_variant | xargs)
engine_version=$(echo $docker_engine_version | xargs)
echo "Running tests for $engine_version with $conn_variant"
# __PLATFORM_VARIANT="${{ matrix.platform-variant }}" __CONNECTION_VARIANT="$conn_variant" __DOCKER_ENGINE_VERSION="$engine_version" pnpm test
done
done
# https://github.com/orgs/community/discussions/26822
pr-can-merge:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [docker-engine-tests]
steps:
- run: exit 1
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}