-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (128 loc) · 4.65 KB
/
test.yaml
File metadata and controls
142 lines (128 loc) · 4.65 KB
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
name: Run Tests
on:
push:
env:
DEVCONTAINER_REGISTRY: ghcr.io
DEVCONTAINER_IMAGE_NAME: ${{ github.repository }}/devcontainer
DEVCONTAINER_IMAGE_TAG_MAIN: "cache-main"
defaults:
run:
shell: bash
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-devcontainer:
runs-on: ubuntu-24.04
outputs:
image_repository: ${{ steps.docker_image.outputs.image_repository }}
image_tag: ${{ steps.docker_image.outputs.image_tag }}
steps:
- uses: actions/checkout@v6
- name: Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DEVCONTAINER_REGISTRY }}/${{ env.DEVCONTAINER_IMAGE_NAME }}
tags: |
type=ref,event=pr,prefix=cache-pr-,priority=600
type=ref,event=branch,prefix=cache-,priority=500
type=ref,event=tag,prefix=cache-,priority=500
flavor: |
latest=false
- name: Extract Docker image name
id: docker_image
env:
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
IMAGE=$(echo "$IMAGE_TAGS" | cut -d" " -f1)
IMAGE_REPOSITORY=$(echo "$IMAGE" | cut -d":" -f1)
IMAGE_TAG=$(echo "$IMAGE" | cut -d":" -f2)
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
echo "image_repository=$IMAGE_REPOSITORY" >> "$GITHUB_OUTPUT"
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-build devcontainer
uses: devcontainers/ci@v0.3
continue-on-error: true
with:
push: always
skipContainerUserIdUpdate: false
imageName: ${{ steps.docker_image.outputs.image_repository }}
imageTag: ${{ steps.docker_image.outputs.image_tag }}
cacheFrom: |
${{ steps.docker_image.outputs.image_repository }}:${{ steps.docker_image.outputs.image_tag }}
${{ steps.docker_image.outputs.image_repository }}:${{ env.DEVCONTAINER_IMAGE_TAG_MAIN }}
tests:
runs-on: ubuntu-24.04
needs:
- build-devcontainer
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/run-image
tags: |
type=ref,event=tag
type=sha,format=short
- name: Build and push run-image
uses: docker/build-push-action@v7
with:
context: ./run-image
file: ./run-image/Dockerfile
platforms: linux/amd64
target: run
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
io.buildpacks.base.distro.name=ubuntu
io.buildpacks.base.distro.version=24.04
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run linting
id: lint
uses: devcontainers/ci@v0.3
with:
runCmd: |
make lint
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Run tests with custom run image
id: tests
uses: devcontainers/ci@v0.3
with:
runCmd: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
go tool tomljson builders/selector/builder.toml | \
go tool yq -p json -o json '.run.images[0].image="'"${{ steps.meta.outputs.tags }}"'"' | \
go tool jsontoml > builders/selector/builder.toml.tmp && \
mv builders/selector/builder.toml.tmp builders/selector/builder.toml
cat builders/selector/builder.toml # Print for debugging
make tests
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}