Skip to content

Commit 4c3edc5

Browse files
committed
[actions] migrate Travis CI tests to GitHub Actions
1 parent 35212c1 commit 4c3edc5

File tree

8 files changed

+444
-97
lines changed

8 files changed

+444
-97
lines changed

.github/workflows/tests-fast.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: 'Tests: fast'
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
fast:
10+
permissions:
11+
contents: read
12+
13+
name: 'fast (${{ matrix.shell }}, ${{ matrix.awk }})'
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
shell:
23+
- sh
24+
- bash
25+
- dash
26+
- zsh
27+
# - ksh
28+
awk:
29+
- gawk
30+
- mawk
31+
32+
steps:
33+
- name: Harden Runner
34+
uses: step-security/harden-runner@v2
35+
with:
36+
allowed-endpoints:
37+
github.com:443
38+
registry.npmjs.org:443
39+
raw.githubusercontent.com:443
40+
nodejs.org:443
41+
iojs.org:443
42+
unofficial-builds.nodejs.org:443
43+
azure.archive.ubuntu.com:80
44+
packages.microsoft.com:443
45+
registry-1.docker.io:443
46+
auth.docker.io:443
47+
production.cloudflare.docker.com:443
48+
- uses: actions/checkout@v6
49+
with:
50+
submodules: true
51+
- name: Install zsh, additional shells, and awk variant
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y zsh ${{ matrix.awk }}
55+
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ] && [ "${{ matrix.shell }}" != "zsh" ]; then
56+
sudo apt-get install -y ${{ matrix.shell }}
57+
fi
58+
# Set the selected awk as the default
59+
sudo update-alternatives --set awk /usr/bin/${{ matrix.awk }}
60+
shell: bash
61+
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
62+
- run: awk --version 2>&1 | head -1 || awk -W version 2>&1 | head -1
63+
- run: curl --version
64+
- run: wget --version
65+
- uses: ljharb/actions/node/install@main
66+
name: 'npm install && version checks'
67+
with:
68+
node-version: 'lts/*'
69+
skip-ls-check: true
70+
- run: npm ls urchin
71+
- run: npx which urchin
72+
- run: env
73+
- name: Hide system node
74+
run: |
75+
if [ -f /usr/local/bin/node ]; then sudo mv /usr/local/bin/node /usr/local/bin/node.bak; fi
76+
if [ -f /usr/local/bin/npm ]; then sudo mv /usr/local/bin/npm /usr/local/bin/npm.bak; fi
77+
if [ -f /usr/local/bin/npx ]; then sudo mv /usr/local/bin/npx /usr/local/bin/npx.bak; fi
78+
shell: bash
79+
- name: Run fast tests
80+
run: |
81+
URCHIN_PATH="$(npx which urchin)"
82+
unset NVM_CD_FLAGS NVM_BIN NVM_INC
83+
export NVM_DIR="${{ github.workspace }}"
84+
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v '\.nvm' | grep -v 'toolcache' | tr '\n' ':')"
85+
make TERM=xterm-256color TEST_SUITE="fast" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.shell }}
86+
- name: Restore system node
87+
if: always()
88+
run: |
89+
if [ -f /usr/local/bin/node.bak ]; then sudo mv /usr/local/bin/node.bak /usr/local/bin/node; fi
90+
if [ -f /usr/local/bin/npm.bak ]; then sudo mv /usr/local/bin/npm.bak /usr/local/bin/npm; fi
91+
if [ -f /usr/local/bin/npx.bak ]; then sudo mv /usr/local/bin/npx.bak /usr/local/bin/npx; fi
92+
shell: bash
93+
94+
all:
95+
permissions:
96+
contents: none
97+
name: 'all fast tests'
98+
needs: [fast]
99+
runs-on: ubuntu-latest
100+
steps:
101+
- run: true
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: 'Tests: installation_iojs'
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
installation_iojs_without_curl:
10+
permissions:
11+
contents: read
12+
13+
name: 'installation_iojs without curl (${{ matrix.shell }})'
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
shell:
23+
- sh
24+
- bash
25+
- dash
26+
- zsh
27+
# - ksh
28+
29+
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@v2
32+
with:
33+
allowed-endpoints:
34+
github.com:443
35+
registry.npmjs.org:443
36+
raw.githubusercontent.com:443
37+
nodejs.org:443
38+
iojs.org:443
39+
azure.archive.ubuntu.com:80
40+
packages.microsoft.com:443
41+
- uses: actions/checkout@v6
42+
with:
43+
submodules: true
44+
- name: Install zsh and additional shells
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y zsh
48+
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ] && [ "${{ matrix.shell }}" != "zsh" ]; then
49+
sudo apt-get install -y ${{ matrix.shell }}
50+
fi
51+
shell: bash
52+
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
53+
- run: wget --version
54+
- uses: ljharb/actions/node/install@main
55+
name: 'npm install && version checks'
56+
with:
57+
node-version: 'lts/*'
58+
skip-ls-check: true
59+
- run: npm ls urchin
60+
- run: npx which urchin
61+
- name: Remove curl
62+
run: sudo apt-get remove curl -y
63+
shell: bash
64+
- run: '! command -v curl'
65+
shell: bash
66+
- run: env
67+
- name: Hide system node
68+
run: |
69+
if [ -f /usr/local/bin/node ]; then sudo mv /usr/local/bin/node /usr/local/bin/node.bak; fi
70+
if [ -f /usr/local/bin/npm ]; then sudo mv /usr/local/bin/npm /usr/local/bin/npm.bak; fi
71+
if [ -f /usr/local/bin/npx ]; then sudo mv /usr/local/bin/npx /usr/local/bin/npx.bak; fi
72+
shell: bash
73+
- name: Run installation_iojs tests
74+
run: |
75+
URCHIN_PATH="$(npx which urchin)"
76+
unset NVM_CD_FLAGS NVM_BIN NVM_INC
77+
export NVM_DIR="${{ github.workspace }}"
78+
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v '\.nvm' | grep -v 'toolcache' | tr '\n' ':')"
79+
make TERM=xterm-256color TEST_SUITE="installation_iojs" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.shell }}
80+
- name: Restore system node
81+
if: always()
82+
run: |
83+
if [ -f /usr/local/bin/node.bak ]; then sudo mv /usr/local/bin/node.bak /usr/local/bin/node; fi
84+
if [ -f /usr/local/bin/npm.bak ]; then sudo mv /usr/local/bin/npm.bak /usr/local/bin/npm; fi
85+
if [ -f /usr/local/bin/npx.bak ]; then sudo mv /usr/local/bin/npx.bak /usr/local/bin/npx; fi
86+
shell: bash
87+
- name: Restore curl
88+
if: always()
89+
run: sudo apt-get install curl -y
90+
shell: bash
91+
92+
all:
93+
permissions:
94+
contents: none
95+
name: 'all installation_iojs tests'
96+
needs: [installation_iojs_without_curl]
97+
runs-on: ubuntu-latest
98+
steps:
99+
- run: true
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: 'Tests: installation_node'
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
installation_node:
10+
permissions:
11+
contents: read
12+
13+
name: "installation_node (${{ matrix.shell }}${{ matrix.without_curl && ', without curl' || '' }})"
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
shell:
20+
- sh
21+
- bash
22+
- dash
23+
- zsh
24+
# - ksh
25+
without_curl:
26+
- false
27+
- true
28+
29+
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@v2
32+
with:
33+
allowed-endpoints:
34+
github.com:443
35+
registry.npmjs.org:443
36+
raw.githubusercontent.com:443
37+
nodejs.org:443
38+
iojs.org:443
39+
azure.archive.ubuntu.com:80
40+
packages.microsoft.com:443
41+
archive.ubuntu.com:80
42+
security.ubuntu.com:80
43+
production.cloudflare.docker.com:443
44+
registry-1.docker.io:443
45+
auth.docker.io:443
46+
- uses: actions/checkout@v6
47+
with:
48+
submodules: true
49+
- uses: ljharb/actions/node/install@main
50+
name: 'npm install && version checks'
51+
with:
52+
node-version: 'lts/*'
53+
skip-ls-check: true
54+
- run: npm ls urchin
55+
- run: npx which urchin
56+
- name: Run installation_node tests in container
57+
run: |
58+
docker run --rm \
59+
-v "${{ github.workspace }}:/workspace" \
60+
-w /workspace \
61+
-e "TEST_SHELL=${{ matrix.shell }}" \
62+
-e "TERM=xterm-256color" \
63+
-e "DEBIAN_FRONTEND=noninteractive" \
64+
-e "GITHUB_ACTIONS=true" \
65+
-e "WITHOUT_CURL=${{ matrix.without_curl }}" \
66+
ubuntu:16.04 \
67+
bash -c '
68+
set -ex
69+
70+
# Retry apt-get update up to 5 times due to flaky Ubuntu mirrors
71+
# apt-get update can return 0 even with partial failures, so check for warnings
72+
for i in 1 2 3 4 5; do
73+
if apt-get update 2>&1 | tee /tmp/apt-update.log | grep -qE "^(W:|E:|Err:)"; then
74+
echo "apt-get update had warnings/errors, attempt $i/5"
75+
cat /tmp/apt-update.log
76+
sleep $((i * 5))
77+
else
78+
break
79+
fi
80+
done
81+
82+
apt-get install -y git curl wget make build-essential python zsh libssl-dev
83+
if [ "$TEST_SHELL" != "sh" ] && [ "$TEST_SHELL" != "bash" ]; then
84+
apt-get install -y $TEST_SHELL || true
85+
fi
86+
87+
# Use nvm to install Node.js for running urchin
88+
# Node 16 is the last version supporting GLIBC 2.23 (Ubuntu 16.04)
89+
export NVM_DIR="/workspace"
90+
. /workspace/nvm.sh
91+
nvm install 16
92+
nvm use 16
93+
94+
npm ls urchin
95+
URCHIN_PATH="$(npx which urchin)"
96+
97+
# Remove curl if testing without it
98+
if [ "$WITHOUT_CURL" = "true" ]; then
99+
apt-get remove curl -y
100+
! command -v curl
101+
fi
102+
103+
# Now clean up nvm state for the actual tests, but keep NVM_DIR set
104+
nvm deactivate || true
105+
nvm unalias default || true
106+
unset NVM_CD_FLAGS NVM_BIN NVM_INC
107+
export PATH="$(echo "$PATH" | tr ":" "\n" | grep -v "\.nvm" | grep -v "toolcache" | tr "\n" ":")"
108+
109+
# Clean any cached files from the nvm install above
110+
rm -rf "$NVM_DIR/.cache" "$NVM_DIR/versions" "$NVM_DIR/alias"
111+
112+
make TEST_SUITE="installation_node" SHELL="$TEST_SHELL" URCHIN="$URCHIN_PATH" test-$TEST_SHELL
113+
'
114+
115+
all:
116+
permissions:
117+
contents: none
118+
name: 'all installation_node tests'
119+
needs: [installation_node]
120+
runs-on: ubuntu-latest
121+
steps:
122+
- run: true

0 commit comments

Comments
 (0)