-
Notifications
You must be signed in to change notification settings - Fork 43
139 lines (123 loc) · 5.42 KB
/
Copy pathdocker-testbed.yml
File metadata and controls
139 lines (123 loc) · 5.42 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
name: Build & Publish docker testbed
# cspell:words buildx
on:
# This job must be manually triggered to publish a new version usable from
# other CI runs.
# (see https://github.com/Scille/parsec-cloud/pkgs/container/parsec-cloud%2Fparsec-testbed-server)
workflow_dispatch:
pull_request:
paths:
# Testbed code also depends on `libparsec/**`, but this code change very often
# and we consider the server tests are good enough on this part.
- server/packaging/testbed-server/**
- "!server/packaging/testbed-server/**.md"
- .github/workflows/docker-testbed.yml
push:
branches:
- master
paths:
# Testbed code also depends on `libparsec/**`, but this code change very often
# and we consider the server tests are good enough on this part.
- server/packaging/testbed-server/**
- "!server/packaging/testbed-server/**.md"
- .github/workflows/docker-testbed.yml
permissions:
contents: write
packages: write
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
# But on the main branch, we don't want that behavior.
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
concurrency:
group: docker-testbed-${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
docker-testbed:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin v7.0.1
timeout-minutes: 5
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Log in to the Github Container registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # pin v7.0.0
id: setup-python
with:
python-version: 3.14
- name: Get current version
id: version
shell: bash
run: python misc/releaser.py version --uniq-dev | tee -a $GITHUB_OUTPUT
timeout-minutes: 1
- name: Generate build metadata
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
id: metadata
with:
images:
ghcr.io/scille/parsec-cloud/parsec-testbed-server
# Manually set some labels:
# - The title to be more specific than just the repo name.
# - The license label as it's not correctly detect by the action
# (internally it use the detected license from github but itself does not support our license)
# - The version labels to the full version.
#
# We use the spec defined here: https://github.com/opencontainers/image-spec/blob/main/annotations.md
labels: |
org.opencontainers.image.title=The Parsec-Cloud testbed server
org.opencontainers.image.licenses=BUSL-1.1
org.opencontainers.image.version=${{ steps.version.outputs.full }}
# We set the same values as labels for annotations
annotations: |
manifest:org.opencontainers.image.title=The Parsec-Cloud testbed server
manifest:org.opencontainers.image.licenses=BUSL-1.1
manifest:org.opencontainers.image.version=${{ steps.version.outputs.full }}
tags: |
type=raw,value=${{ steps.version.outputs.docker }}
flavor: |
latest=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and export to Docker
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
id: build
with:
context: .
file: server/packaging/testbed-server/testbed-server.dockerfile
load: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: false
timeout-minutes: 20
- name: Start docker test container
id: test-container
shell: bash
run: |
(
echo -n "id=";
docker run --detach --publish 6777:6777 --rm --name=parsec-testbed-server ${{ steps.build.outputs.imageid }}
) | tee $GITHUB_OUTPUT
timeout-minutes: 1
- name: Test docker image
run: python .github/scripts/test-server.py
timeout-minutes: 1
- name: Stop docker test container
run: docker container stop ${{ steps.test-container.outputs.id }}
timeout-minutes: 1
- name: Image to be published
run: echo "${{ steps.metadata.outputs.tags }}"
- name: Build and publish
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: server/packaging/testbed-server/testbed-server.dockerfile
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: true
timeout-minutes: 5