-
-
Notifications
You must be signed in to change notification settings - Fork 702
132 lines (130 loc) · 6.7 KB
/
test.yml
File metadata and controls
132 lines (130 loc) · 6.7 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
on:
push:
branches:
# Do not build PRs twice
- 'master'
paths:
- 'data/**'
pull_request:
paths:
- 'data/**'
env:
DISPLAY: :99
IS_PULLREQUEST: ${{ github.event_name == 'pull_request' }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# https://github.com/actions/checkout#Fetch-all-history-for-all-tags-and-branches
# According to the docs for checkout@v2, Only a single commit is fetched by default, but
# providing a fetch-depth of 0 should fetch all history.
with:
fetch-depth: 0
- name: Configure APT Packages
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
# This action handles caching APT packages, and leaves the option for package configuration scripts to be run if needed,
# saving a boat-load of time, if needed bump the action version.
with:
packages: sudo imagemagick libasound2-dev pulseaudio-utils alsa-utils alsa-oss libjack0 desktop-file-utils xmlstarlet xsel xterm xvfb icewm x11-utils x11-apps netpbm xdotool libgl1-mesa-dri libgl1-mesa-dev mesa-utils libosmesa6 libsdl1.2-dev libsdl2-2.0-0 fonts-wqy-microhei libfile-mimeinfo-perl
version: 1.0
# Bump me ^ if you have added any new packages
- name: Install dependencies
shell: bash
run: |
# set -e
sudo bash code/prep-dummy-soundcard.sh
# TODO Cache gem and npm packages
sudo gem install dupervisor -v 1.0.5 # To convert ini to yaml files
sudo npm install -g asar # to get pacakges.json from resources/app.asar for electron-builder applications
# npm install -g @alexlafroscia/yaml-merge # to merge yaml files
- name: Main test
uses: nick-fields/retry@v3
with:
max_attempts: 5
retry_wait_seconds: 60
warning_on_retry: true
command: |
# set -e
mkdir $HOME/.icewm/
echo "ShowTaskBar = 0" > $HOME/.icewm/preferences
echo "TaskBarAutoHide = 1" > $HOME/.icewm/preferences
echo "TaskBarShowWorkspaces = 0" > $HOME/.icewm/preferences
echo "TaskBarShowAllWindows = 0" > $HOME/.icewm/preferences
echo "TaskBarShowClock = 0" > $HOME/.icewm/preferences
echo "TaskBarShowMailboxStatus = 0" > $HOME/.icewm/preferences
echo "TaskBarShowCPUStatus = 0" > $HOME/.icewm/preferences
echo "TaskBarShowWindowListMenu = 0" > $HOME/.icewm/preferences
# xpra start :99 # Cannot get screenshots to work
Xvfb :99 -screen 0 800x600x24 >/dev/null 2>&1 & # Need to set bit depth, otherwise get some black screenshots
# until xset -q; do echo "Waiting for X server to start..."; sleep 1; done # We are not immediately using it anyway
# Find out which files in data/ have been changed in the last commit
#set -x # Debug #379
FILES=$(git log -1 -p data/ | grep +++ | cut -d '/' -f 2-| sed -e 's|dev/null||g')
# Finds wrong files in PRs! # FILES=$(git log -1 --name-status --diff-filter=AR --pretty=format: -- data/ | awk '/^A/ || /^R/ {file=$2} END {print file}') # Most recent addition or renaming within the last commit
echo "Last changed files from the FILES variable:"
echo "$FILES" ; if [ -z "$FILES" ] ; then echo "Variable FILES is empty." && exit 1 ; fi
# Work on these files that have been changed in the last commit
if [ -n "$FILES" ]; then
for FILE in $FILES; do
echo "$FILE"
bash -e code/worker.sh $(readlink -f "$FILE") 2>&1 | tee log.txt
EXIT_CODE=${PIPESTATUS[0]} # bashism; get the return code of the leftmost element of the pipe
if [ $EXIT_CODE -ne 0 ]; then
echo "worker.sh exited with a non-zero code: $EXIT_CODE"
exit $EXIT_CODE
fi
done
fi
# xpra stop :99
killall Xvfb
# bundle exec jekyll build # https://help.github.com/en/articles/viewing-jekyll-build-error-messages#configuring-a-third-party-service-to-display-jekyll-build-error-messages
- name: Check log
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'probonopd'
shell: bash
run: |
cat log.txt | wc -l
grep -r "Running as root without --no-sandbox is not supported" log.txt && MESSAGE="Pending #2563 (\`Running as root without --no-sandbox is not supported\`)." && exit 1
grep -r "version \`GLIBC_.*' not found" && MESSAGE="This was compiled on a too new system and hence cannot run on all still-supported versions of Ubuntu." && exit 1
echo "${MESSAGE}"
SCREENSHOT_URL=$(cat log.txt | grep -o -e "https://i.imgur.com.*.png") || true
if [[ -z "${SCREENSHOT_URL}" ]]; then
echo "No screenshot URL found."
exit 1
fi
echo "SCREENSHOT_URL=$SCREENSHOT_URL" >> $GITHUB_ENV || true
echo "SCREENSHOT_URL: ${SCREENSHOT_URL}" || true
# The following is disabled because it gives errors about missing permissions
# whenever a PR is made by anyone but the repo maintainer
# - name: Post Screenshot URL
# if: ${{ always() && github.event_name == 'pull_request' && github.run_status != 'cancelled' }}
# uses: actions/github-script@v6
# with:
# script: |
# const prNumber = context.payload.pull_request.number;
# const screenshotURL = process.env.SCREENSHOT_URL;
# if (screenshotURL) {
# const commentBody = `Seems like the test succeeded. Temporary screenshot URL: ${screenshotURL}`;
# await github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: prNumber,
# body: commentBody
# });
# } else {
# const runURL = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}`;
# const commentBody = `The test was unable to make a screenshot. Most likely, the test did not succeed. Please check the [logs of the test run](${runURL}).`;
# await github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: prNumber,
# body: commentBody
# });
# core.setFailed("Unable to post screenshot");
# }