-
-
Notifications
You must be signed in to change notification settings - Fork 7
167 lines (148 loc) · 5.77 KB
/
ci.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
159
160
161
162
163
164
165
166
167
name: Lint, test and publish
on: [push, pull_request]
jobs:
php-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- run: |
composer install --prefer-source --quiet --no-interaction
composer test
caddy-fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Format caddyfile
run: |
cd development
cp Caddyfile Caddyfile.orig
docker run -v $PWD:/srv caddy \
caddy fmt --overwrite
diff Caddyfile.orig Caddyfile
etc-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get yarn cache
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Lint
run: |
yarn --dev
yarn run lint
docker-image:
name: Docker image test and publishing
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Edit configuration
run: |
mv configs/secret.php.example development/secret.php
mv configs/LocalSettings.php development
mv configs/Hotfix.php development
sed -i -r 's~ghcr\.io\/femiwiki\/mediawiki:.+~ghcr\.io\/femiwiki\/mediawiki:docker-test~' docker-compose.yml
- run: |
echo "version=$(date +%Y-%m-%dT%H-%M)-$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT
id: version
- name: Build a test image on amd64 and cache
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
cache-from: ghcr.io/femiwiki/mediawiki:latest
cache-to: mode=max,type=local,dest=/tmp/.buildx-cache
load: true
push: false
tags: ghcr.io/femiwiki/mediawiki:docker-test
- name: Initialize docker swarm and start services
run: |
docker swarm init
docker stack deploy -c docker-compose.yml mediawiki
- name: Access 127.0.0.1:8080 until success
timeout-minutes: 3
run: |
echo 'Waiting for http...'
until curl -sLfo /dev/null 127.0.0.1:8080; do
sleep 1; done
- name: Test VisualEditor API
run: |
URL="127.0.0.1:8080/api.php?action=visualeditor&format=json&page=arbitrary_page&paction=parse&wikitext=arbitrary"
curl -sLfo /dev/null "$URL"
- name: Test Extension:Math
timeout-minutes: 1
run: |
URL="127.0.0.1:8080/w/Special:MathStatus"
until curl -sLfo /dev/null "$URL"; do
sleep 1; done
- name: backup of failure
if: ${{ failure() }}
timeout-minutes: 1
run: |
echo 'Failed to connect to 127.0.0.1:8080'
URL="127.0.0.1:8080/api.php?action=visualeditor&format=json&page=arbitrary_page&paction=parse&wikitext=arbitrary"
curl -Lv "$URL" && echo "VE success" || echo "VE failure"
URL="127.0.0.1:8080/w/Special:MathStatus"
curl -Lv "$URL" && echo "Math success" || echo "Math failure"
docker ps;
for s in $(docker service ls -q ); do docker service ps "$s"; done
docker container ps;
for s in $(docker service ls -q ); do docker service logs "$s"; done
- name: Check if the container is still up
run: test "$(docker service ps -qf 'desired-state=Running' -f 'desired-state=Ready' mediawiki_fastcgi)"
- name: Try to access the mediawiki
run: curl -sSLvo /dev/null 127.0.0.1:8080 || docker service logs mediawiki_fastcgi
- name: Login to GitHub Container Registry
if: github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: save docker image
run: docker save -o "$(pwd)/docker-mediawiki" ghcr.io/femiwiki/mediawiki:docker-test
- uses: actions/upload-artifact@v3
with:
name: docker-image
path: docker-mediawiki
- name: Build a multi-platform docker image and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
cache-from: |
ghcr.io/femiwiki/mediawiki:latest
type=local,src=/tmp/.buildx-cache
cache-to: mode=max,type=inline
load: false
push: ${{ github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/femiwiki/mediawiki:latest
ghcr.io/femiwiki/mediawiki:${{ steps.version.outputs.version }}
- name: Submit a PR to our nomad repository
if: github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
gh workflow run -R femiwiki/nomad bump-mediawiki.yml \
-f tag=${{ steps.version.outputs.version }}