-
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (131 loc) · 5.39 KB
/
Copy pathtest.yml
File metadata and controls
155 lines (131 loc) · 5.39 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
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Test
on:
pull_request:
branches:
- main
- 'feature/**'
push:
branches:
- main
jobs:
test:
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Test, Arch amd64
arch: amd64
os: ubuntu-latest
container: ''
- name: Test, Arch arm64
arch: arm64
os: ubuntu-24.04-arm
container: ''
# The custom runner job validates the containerised CI environment
# that consumer projects run the seeding in. Linting and coverage
# run only in this job because the ci-runner image bundles shfmt
# and kcov.
- name: Test, Arch amd64, custom runner
arch: amd64
os: ubuntu-latest
# https://hub.docker.com/r/drevops/ci-runner
container: drevops/ci-runner:26.6.0@sha256:190027056cac7b7ce28c29a1e5494779ebadc4ee8e95d468b75bc56e7be5aabd
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Configure Git safe directory
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Check out the repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Lint shell scripts
if: matrix.container != ''
run: |
shfmt -i 2 -ci -s -d seed.sh tests/bats/*.bash tests/bats/*.bats
shellcheck seed.sh tests/bats/*.bash tests/bats/*.bats
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}
- name: Install goss
run: |
GOSS_VERSION=v0.4.9
mkdir -p "${HOME}/bin"
curl -fsSL "https://github.com/goss-org/goss/releases/download/${GOSS_VERSION}/goss-linux-${{ matrix.arch }}" -o "${HOME}/bin/goss"
curl -fsSL "https://github.com/goss-org/goss/releases/download/${GOSS_VERSION}/dgoss" -o "${HOME}/bin/dgoss"
chmod +rx "${HOME}/bin/goss" "${HOME}/bin/dgoss"
"${HOME}/bin/goss" --version
- name: Build Docker image
run: docker build -t gosstestorg/gosstestimage:goss-test-tag .
- name: Run Goss tests
run: |
export GOSS_FILES_STRATEGY=cp
export GOSS_PATH="${HOME}/bin/goss"
GOSS_FILES_PATH=tests/dgoss "${HOME}/bin/dgoss" run -i gosstestorg/gosstestimage:goss-test-tag
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
- name: Install BATS dependencies
run: npm --prefix tests/bats ci
- name: Run BATS tests with code coverage
if: matrix.container != ''
run: |
echo "${DOCKER_PASS}" | docker login --username "${DOCKER_USER}" --password-stdin
kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,coverage $(pwd)/coverage tests/bats/node_modules/.bin/bats tests/bats
shell: bash
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
- name: Run BATS tests
if: matrix.container == ''
run: |
echo "${DOCKER_PASS}" | docker login --username "${DOCKER_USER}" --password-stdin
tests/bats/node_modules/.bin/bats tests/bats
shell: bash
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
- name: Upload coverage report as an artifact
if: matrix.container != ''
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{github.job}}-code-coverage-report
include-hidden-files: true
path: coverage
if-no-files-found: error
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
if: ${{ matrix.container != '' && env.CODECOV_TOKEN != '' }}
with:
directory: coverage
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
push-canary-to-registry:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Log in to Docker Hub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: drevops/mariadb-drupal-data
- name: Build and push Docker image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
push: true
tags: drevops/mariadb-drupal-data:canary
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64