-
-
Notifications
You must be signed in to change notification settings - Fork 173
181 lines (178 loc) · 7.13 KB
/
tests.yml
File metadata and controls
181 lines (178 loc) · 7.13 KB
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
name: tests
on:
pull_request: {}
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
defaults:
run:
shell: bash
jobs:
run-tests:
strategy:
matrix:
OS: ["ubuntu:latest", "ubuntu:devel", "ubuntu:rolling", "debian:stable", "debian:testing", "debian:unstable"]
PACSTALL_VERSION: ["master", "develop"]
fail-fast: false
runs-on: ubuntu-latest
container:
image: ${{ matrix.OS }}
options: --privileged
env:
TERM: xterm
shell: bash
USER: dio
LOGNAME: dio
DEBIAN_FRONTEND: noninteractive
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- id: checkout
uses: actions/checkout@v6
- id: paths
uses: dorny/paths-filter@v3
with:
filters: |
pacscripts:
- 'packages/*/*.pacscript'
- id: files
uses: Ana06/get-changed-files@v2.3.0
- name: Check for Pacscript changes
run: |
touch .no-pacscript-changes
for changed_file in ${{ steps.files.outputs.added_modified }}; do
if [[ ${changed_file} == *".pacscript" ]]; then
rm -f .no-pacscript-changes
break
fi
done
- name: Install System Utilities
if: steps.paths.outputs.pacscripts == 'true'
run: |
dpkg --add-architecture i386
dpkg --add-architecture arm64
if [[ $(awk -F= '$1=="ID" { print $2 }' /etc/os-release) == "ubuntu" ]]; then
source /etc/os-release && echo "Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: ${VERSION_CODENAME} ${VERSION_CODENAME}-updates ${VERSION_CODENAME}-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures-Remove: amd64 i386
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: ${VERSION_CODENAME}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures-Remove: amd64 i386
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: ${VERSION_CODENAME} ${VERSION_CODENAME}-updates ${VERSION_CODENAME}-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures-Remove: arm64
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: ${VERSION_CODENAME}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures-Remove: arm64" | tee /etc/apt/sources.list.d/ubuntu.sources && rm -f /etc/apt/sources.list
fi
apt-get update
apt-get install apt-utils curl ca-certificates bash wget git sudo iputils-ping keyboard-configuration lsb-release desktop-file-utils -y --no-install-recommends
ln -fs /usr/share/zoneinfo/Africa/Libreville /etc/localtime
- name: Setup Test User
if: steps.paths.outputs.pacscripts == 'true'
run: |
useradd -rm -d /home/$USER -s /bin/bash -g root -G sudo -u 1001 $USER
sudo sed -i "s/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL) NOPASSWD:ALL/g" /etc/sudoers
chown -R $USER /tmp
chmod -R 777 /tmp
- name: Installing Pacstall
if: steps.paths.outputs.pacscripts == 'true'
run: |
export SUDO_USER=$USER
curl -fsSL https://pacstall.dev/q/install\?dnt > pacstall-install.sh || curl -fsSL https://git.io/JsADh > pacstall-install.sh
chmod +x ./pacstall-install.sh
echo N\n | sudo -E ./pacstall-install.sh
rm ./pacstall-install.sh
sudo sed -i 's/ignore_stack=false/ignore_stack=true/g' /usr/bin/pacstall
pacstall -U pacstall ${{ matrix.PACSTALL_VERSION }}
ls -lad /tmp/pacstall
shell: sudo -E -u dio bash {0}
env:
SUDO_USER: dio
- name: Installing Packages
if: steps.paths.outputs.pacscripts == 'true'
run: |
export SUDO_USER=$USER
export DEBIAN_FRONTEND=noninteractive
export GITHUB_ACTIONS=true
export METADIR=/var/lib/pacstall/metadata
PRNUM="$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"
for changed_file in ${{ steps.files.outputs.added_modified }}; do
if [[ ${changed_file} == *".pacscript" ]]; then
pacscript_file=`basename "${changed_file}"`
package_name="${pacscript_file/.pacscript/}"
if [[ -f "${METADIR}/${package_name}" ]]; then
echo "Package ${package_name} has already been installed."
else
echo "Running pacstall -Qa for ${package_name}..."
echo "pacstall -Qa ${package_name}#${PRNUM}@github:${GITHUB_REPOSITORY}"
pacstall -Qa ${package_name}#${PRNUM}@github:${GITHUB_REPOSITORY} || exit 1
fi
fi
done
shell: sudo -E -u dio bash {0}
env:
DEBIAN_FRONTEND: noninteractive
- name: Output Package Trees
if: steps.paths.outputs.pacscripts == 'true'
run: |
export SUDO_USER=$USER
export DEBIAN_FRONTEND=noninteractive
export GITHUB_ACTIONS=true
mapfile -t list < <(pacstall -L)
for pkg in "${list[@]}"; do
echo "${pkg}:"
pacstall -T "${pkg}"
echo "---"
done
shell: sudo -E -u dio bash {0}
env:
DEBIAN_FRONTEND: noninteractive
- name: Uninstalling Packages
if: steps.paths.outputs.pacscripts == 'true'
run: |
export SUDO_USER=$USER
export DEBIAN_FRONTEND=noninteractive
export GITHUB_ACTIONS=true
export METADIR=/var/lib/pacstall/metadata
function array.contains() {
local check
local -n arra="${1:?No array passed to array.contains}"
local input="${2:?No input given to array.contains}"
for check in "${arra[@]}"; do
if [[ ${check} == "${input}" ]]; then
return 0
fi
done
return 1
}
function stacktrace() {
catch=$?
return "${catch}"
}
source /usr/share/pacstall/scripts/dep-tree.sh
mapfile -t list < <(pacstall -L)
dep_tree.loop_traits order "${list[@]}"
for changed_file in "${order[@]}"; do
echo "Running pacstall -R for ${changed_file}..."
pacstall --disable-prompts -R ${changed_file} || exit 1
done
shell: sudo -E -u dio bash {0}
env:
DEBIAN_FRONTEND: noninteractive