-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (131 loc) · 4.11 KB
/
test.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
# Copyright (C) 2013 - 2021 Tim Düsterhus
# Copyright (C) 2021 Maximilian Mader
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Test
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
cargo_build:
name: cargo build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
- run: npm ci
- run: cargo build --locked --verbose
- uses: actions/upload-artifact@v3
with:
name: tims-package-server
path: target/*/tims-package-server
if-no-files-found: error
retention-days: 2
cargo_test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
- run: npm ci
- run: cargo test --locked --verbose
end_to_end_test:
name: End to end test
needs:
- cargo_build
runs-on: ubuntu-latest
steps:
- run: sudo apt-get update
- run: sudo apt-get install -y httpie jq
- run: pip3 install yq
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tims-package-server
- run: mv */tims-package-server .
- run: chmod +x ./tims-package-server
- run: sudo systemd-run --unit=tims-package-server --same-dir --uid="$(id -u)" ./tims-package-server
- run: systemctl status tims-package-server
- name: Wait for the HTTP service to come up
run: |
set -x
success=
for _ in $(seq 5); do
if [ "200" == "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:9001)" ]; then
success=1
break
fi
sleep 1
done
if [ -z "$success" ]; then
echo "::error::The HTTP service did not come up." >&2
exit 1
fi
- name: Build packages
run: |
set -x
pushd tests/
for package in be.bastelstu.*; do
mkdir "../packages/$package/"
pushd "$package"
for version in *.xml; do
tar cf "../../packages/$package/$(basename "$version" ".xml").tar" $version --transform 's~.*~package.xml~'
done
popd
done
popd
shell: bash
- name: Grab initial ETag
id: etag
run: printf "ETAG=%s" "$(curl -fsSi http://localhost:9001/ |awk '/^etag:/{print $2}' |tr -d '\r\n')" >> $GITHUB_OUTPUT
- run: mv tests/auth.json packages/auth.json
- name: Wait for the ETag to change
run: |
set -x
success=
for _ in $(seq 30); do
if [ "200" == "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:9001/ -H 'if-none-match: ${{ steps.etag.outputs.ETAG }}')" ]; then
success=1
break
fi
sleep 1
done
if [ -z "$success" ]; then
echo "::error::The ETag did not change." >&2
exit 1
fi
if [ "$(curl -fsSi http://localhost:9001/ |awk '/^etag:/{print $2}' |tr -d '\r\n')" = '${{ steps.etag.outputs.ETAg }}' ]; then
echo "::error::The ETag did not change." >&2
exit 1
fi
- run: http --pretty=all -v GET :9001/
- run: sudo systemctl stop tims-package-server