-
Notifications
You must be signed in to change notification settings - Fork 2
137 lines (123 loc) · 4.24 KB
/
src.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
name: Source
on:
push:
branches:
- src
pull_request:
branches:
- src
jobs:
local:
name: Local test
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ '3.8.2', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "FNNDSC in Github Actions"
- name: Run ./bootstrap.sh
run: |
sed -i -e 's/#READY=yes/READY=yes/' bootstrap.sh
./bootstrap.sh
- name: Generated unit tests
run: |
source venv/bin/activate
pytest
- name: Run program
run: |
source venv/bin/activate
echo 'on-the-metal test is very testy test test' /tmp/ghaction.txt
commandname --word 'test' /tmp ./outgoing
if ! [ -e 'outgoing/ghaction.count.txt' ]; then
echo "Contents of outgoing: " outgoing/*
echo "::error ::File outgoing/ghaction.count.txt was not created."
fi
integration:
name: Integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Edit code
run: |
git config --global user.email "[email protected]"
git config --global user.name "FNNDSC in Github Actions"
temp_file=$(mktemp)
sed 's/#READY=yes/READY=yes/' bootstrap.sh \
| sed 's/^PLUGIN_NAME=.*/PLUGIN_NAME=pl-ghactions-testtemplate/' \
| sed 's/^SCRIPT_NAME=.*/SCRIPT_NAME=ghtest_template/' \
| sed 's/^PLUGIN_TITLE=.*/PLUGIN_TITLE="A test in GH Actions"/' \
> $temp_file
mv $temp_file ./bootstrap.sh
chmod +x bootstrap.sh
./bootstrap.sh
if ! [ -f ghtest_template.py ]; then
echo "::error ::File ghtest_template.py was not created."
exit 1
fi
# change the version of this ChRIS plugin
sed -i -e 's/^__version__ = .*/__version__ = "1.2.3"/' ghtest_template.py
- name: Build image
run: docker build -t localhost/fnndsc/pl-ghactions-testtemplate:1.2.3 .
- name: Spin up ChRIS
uses: FNNDSC/miniChRIS-docker@master
with:
plugins: localhost/fnndsc/pl-ghactions-testtemplate:1.2.3
- name: Assert plugin registered
run: |
qs='name_exact=pl-ghactions-testtemplate&version=1.2.3'
res="$(
curl -u 'chris:chris1234' \
-H 'Accept: application/json' \
"http://localhost:8000/api/v1/plugins/search/?$qs"
)"
count="$(jq -r '.count' <<< "$res")"
if [ "$count" != '1' ]; then
echo "::error ::expected count=1"
echo "$res"
exit 1
fi
push:
name: Push to main
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [ local, integration ]
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Configure git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Merge ref into main
run: |
git switch main
set +e
output="$(git merge --no-ff --no-commit ${{ github.ref }})"
set -e
echo "$output"
# ignore merge conflicts to this file
filtered="$(sed '/CONFLICT (modify\/delete): \.github\/workflows\/src\.yml/d' <<< "$output")"
if ( echo "$filtered" | grep -Fq CONFLICT ); then
echo "::error ::Unacceptable merge conflict. Someone changed main, please merge manually."
exit 1
fi
# Important! Deletes this Github workflow file
if [ -e .github/workflows/src.yml ]; then
git rm --force .github/workflows/src.yml
fi
git commit --no-edit
- name: Push to main
uses: ad-m/github-push-action@552c074ed701137ebd2bf098e70c394ca293e87f
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main