-
Notifications
You must be signed in to change notification settings - Fork 7
205 lines (181 loc) · 6.3 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: CI
on:
push:
branches:
- main
tags:
- 'v*.*.*'
schedule:
- cron: "0 6 * * *"
jobs:
unit_tests:
name: Run unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
koha-version: [main, stable, oldstable]
steps:
- name: Is a tag?
run: |
echo "${{ startsWith(github.ref, 'refs/tags/v') }}"
- name: GitHub Ref 1
run: |
echo "${GITHUB_REF##*/}"
- name: GitHub Ref 2
run: |
echo "${{ github.event.ref }}"
- name: GitHub Ref 3
run: |
echo "${{ github.ref }}"
- name: Dump env
run: env | sort
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v1
- name: Get Koha Version Branch Name
id: koha-version
uses: "bywatersolutions/github-action-koha-get-version-by-label@master"
with:
version-label: "${{ matrix.koha-version }}"
- name: Check out Koha
run: |
cd ..
git clone --branch ${{ steps.koha-version.outputs.current-branch-name }} --single-branch --depth 1 https://github.com/Koha-Community/Koha.git kohaclone
- name: Export additional variables needed by koha-testing-docker
run: |
cd ..
pwd
ls -alh
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY"
export GITHUB_REPO="${parts[1]}"
export ROOT_DIR="$(pwd)"
export LOCAL_USER_ID="$(id -u)" # Needed for koha-testing-docker
export SYNC_REPO="$ROOT_DIR/kohaclone"
export KOHA_INTRANET_URL="http://127.0.0.1:8081"
export KOHA_MARC_FLAVOUR="marc21"
echo "GITHUB_REPO=$GITHUB_REPO" >> $GITHUB_ENV
echo "ROOT_DIR=$ROOT_DIR" >> $GITHUB_ENV
echo "LOCAL_USER_ID=$LOCAL_USER_ID" >> $GITHUB_ENV
echo "SYNC_REPO=$SYNC_REPO" >> $GITHUB_ENV
echo "KOHA_INTRANET_URL=$KOHA_INTRANET_URL" >> $GITHUB_ENV
echo "KOHA_MARC_FLAVOUR=$KOHA_MARC_FLAVOUR" >> $GITHUB_ENV
echo "RUN_TESTS_AND_EXIT=no" >> $GITHUB_ENV
echo "KOHA_IMAGE=main" >> $GITHUB_ENV
echo "GITHUB REPO: $GITHUB_REPO"
echo "ROOT DIR: $ROOT_DIR"
echo "SYNC_REPO: $SYNC_REPO"
ls -alh $SYNC_REPO
- name: Set up koha-testing-docker
run: |
sudo sysctl -w vm.max_map_count=262144
wget -O docker-compose.yml https://gitlab.com/koha-community/koha-testing-docker/raw/main/docker-compose.yml
mkdir -p env
wget -O env/defaults.env https://gitlab.com/koha-community/koha-testing-docker/raw/main/env/defaults.env
cp env/defaults.env .env
docker compose pull
# - name: Setup Debug Session
# uses: csexton/debugger-action@master
- name: Run tests
run: |
pwd
ls -alh
docker compose -f docker-compose.yml -p koha up --detach
cd ..
pwd
ls -alh
echo "KTD: Waiting for KTD to warm up"
for i in $(seq 1 200); do
if docker exec koha-koha-1 bash -c '[ -e /ktd_ready ]'; then
printf "\n"
break
elif [ "$i" != "200" ]; then
printf "\rAttempt $i of 200"
sleep 1
else
printf "KTD: Timeout waiting for KTD to be ready (ERROR)"
exit 1
fi
done
echo "KTD: ready!"
docker cp $GITHUB_REPO/. koha-koha-1:/var/lib/koha/kohadev/plugins
docker exec koha-koha-1 bash -c 'prove /var/lib/koha/kohadev/plugins/t'
- name: Post test cleanup
run: |
docker compose down
docker rm -f $(docker ps -a -f "name=koha-" -q)
docker volume prune -f
docker image prune -f
rm docker-compose.yml
rm -rf env .env
release:
name: Build & Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: unit_tests
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v1
- name: Parse out and store the GitHub repository name
id: myvars
run: |
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY"
GITHUB_REPO="${parts[1]}"
echo ::set-output name=github_repo::$GITHUB_REPO
echo "GITHUB REPO: $GITHUB_REPO"
TAG_VERSION="${GITHUB_REF##*/}"
echo "TAG VERSION: $TAG_VERSION"
TAG_VERSION="${TAG_VERSION:1}"
echo "TAG VERSION 2: $TAG_VERSION"
echo ::set-output name=tag_version::$TAG_VERSION
- name: Get Koha Version Branch Name
id: koha-version-oldstable
uses: "bywatersolutions/github-action-koha-get-version-by-label@master"
with:
version-label: "oldstable"
- name: Print minimum version
run: |
echo "Current oldstable version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }}"
- name: Dump myvars outputs
env:
GITHUB_CONTEXT: ${{ toJson(steps.myvars.outputs) }}
run: echo "$GITHUB_CONTEXT"
- name: Build Koha Plugin kpz artifact
id: kpz
uses: "bywatersolutions/github-action-koha-plugin-create-kpz@master"
with:
release-version: ${{ steps.myvars.outputs.tag_version }}
release-name: ${{ steps.myvars.outputs.github_repo }}
minimum-version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }}
plugin-module: "Koha/Plugin/Com/ByWaterSolutions/CurbsidePickup.pm"
- name: See if kpz was created
run: |
echo "FILENAME: ${{ steps.kpz.outputs.filename }}"
ls -alh
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ steps.kpz.outputs.filename }}
CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
keepalive:
name: Keep Alive
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check age and push commit if needed
run: |
LAST_COMMIT=$( git --no-pager log -1 --format=%ct )
NOW=$(date +%s)
DIFF=$(($NOW-$LAST_COMMIT))
DAYS=$(($DIFF/86400))
git config --global user.email [email protected]
git config --global user.name "Kyle M Hall"
git commit --allow-empty -m "Automated commit from keep alive workflow"
if [ "$DAYS" -gt "50" ]; then git push; fi