-
-
Notifications
You must be signed in to change notification settings - Fork 17
157 lines (131 loc) · 4.83 KB
/
unit-tests.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
name: "Unit tests"
on:
repository_dispatch:
types: ["Unit tests"]
schedule:
- cron: '0 2 * * *'
pull_request:
types: [opened, reopened, edited, synchronize, review_requested]
# paths:
# - 'tests/*.conf'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
concurrency:
group: pipeline-pr-${{github.event.pull_request.number}}
cancel-in-progress: true
jobs:
test:
name: "Unit tests"
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.json.outputs.JSON_CONTENT}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: 'config'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v43
with:
path: config
files: |
tests/*.conf
- name: "Make JSON ${{ steps.changed-files.outputs.all_changed_files }}"
id: json
run: |
echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT
# define docker images where we will run test install
dockerimages=("debian:bookworm" "debian:trixie" "ubuntu:jammy" "ubuntu:noble")
# read tests cases and loop them
if [[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]]; then
tests=($(echo ${{ steps.changed-files.outputs.all_changed_files }} | tr " " "\n" | cut -d"." -f1 | cut -d"/" -f2))
else
tests=($(grep -rw config/tests/*.conf -e "ENABLED=true" | cut -d"/" -f3 | cut -d"." -f1))
fi
for i in "${tests[@]}"; do
unset RELEASE
source config/tests/${i}.conf
if [[ -z "${RELEASE}" ]]; then RELEASE=all; fi
# if we speficy releases, we need to loop docker images and use if there is a match
if [[ $RELEASE != all || -z $RELEASE ]]; then
for j in ${dockerimages[@]}; do
elements=($(echo $RELEASE | tr ':' "\n"))
for SELECTED_RELEASE in "${elements[@]}"; do
if [[ $j == *"${SELECTED_RELEASE}"* ]]; then
echo "{\"package\":\"${i}\",\"image\":\"$j\"}"
fi
done
done
else
for j in ${dockerimages[@]}; do
echo "{\"package\":\"${i}\",\"image\":\"$j\"}"
done
fi
done | jq -s >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
gradle:
needs: test
strategy:
fail-fast: false
max-parallel: 32
matrix:
image: ${{ fromJSON(needs.test.outputs.matrix) }}
name: "I"
runs-on: ubuntu-latest
container:
image: "${{ matrix.image.image }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: 'config'
- name: Install
run: |
# source vars
. "config/tests/${{ matrix.image.package }}.conf"
echo ${TEST_TITLE}
export DEBIAN_FRONTEND=noninteractive
RELEASE=$(echo "${{ matrix.image.image }}" | cut -d":" -f2)
apt update
apt -y install wget gpg
# add armbian repository
URL=apt.armbian.com
wget https://${URL}/armbian.key -O key
gpg --dearmor < key | tee /usr/share/keyrings/armbian.gpg > /dev/null
chmod go+r /usr/share/keyrings/armbian.gpg
echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] http://${URL} $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" | tee /etc/apt/sources.list.d/armbian.list
apt update -y
apt upgrade -y
apt -y install sudo procps systemd whiptail jq lsb-release iproute2
# install packages / except howdy as its too large
export DEBIAN_FRONTEND=noninteractive
cd config
eval "$PREINSTALL"
sudo bash bin/armbian-configng --cmd "${{ matrix.image.package }}"
eval "$CONDITION"
# stats
FILENAME="data-"$(echo ${{ matrix.image.image }} | sed "s/:/-/g")"-${{ matrix.image.package }}.teststats"
echo $RELEASE >> ../${FILENAME}
bash bin/armbian-configng --cmd | grep "${{ matrix.image.package }}" | xargs >> ../${FILENAME}
echo " " >> ../${FILENAME}
- name: Upload test
uses: actions/[email protected]
with:
name: TESTDATA
path: data-*.teststats
stop:
name: "Merge test artifacts"
if: always()
needs: gradle
runs-on: ubuntu-latest
steps:
- name: "Download changes"
uses: actions/[email protected]
with:
name: TESTDATA
- name: Install
run: |
echo "# Succesful tests:" >> $GITHUB_STEP_SUMMARY
cat ./*.teststats | sed '$ s/.$//' >> $GITHUB_STEP_SUMMARY