Test with root access in GitHub workflows #68
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Core | |
- build: unit | |
os: ubuntu-latest | |
# Modules | |
- build: go-1.21 | |
os: ubuntu-latest | |
- build: go-1.22 | |
os: ubuntu-latest | |
- build: java-17 | |
os: ubuntu-latest | |
- build: java-18 | |
os: ubuntu-latest | |
- build: java-21 | |
os: ubuntu-latest | |
- build: node-20 | |
os: ubuntu-latest | |
- build: node-21 | |
os: ubuntu-latest | |
- build: perl | |
os: ubuntu-latest | |
- build: php-8.1 | |
os: ubuntu-latest | |
- build: php-8.2 | |
os: ubuntu-latest | |
- build: php-8.3 | |
os: ubuntu-latest | |
- build: python-3.11 | |
os: ubuntu-latest | |
- build: python-3.12 | |
os: ubuntu-latest | |
- build: ruby-3.2 | |
os: ubuntu-latest | |
- build: ruby-3.3 | |
os: ubuntu-latest | |
- build: wasm | |
os: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Provides module, language version and testpath from build name | |
- name: Output build metadata | |
id: metadata | |
run: | | |
# Split the build name by '-' into module and version | |
IFS='-' read -r module version <<< "${{ matrix.build }}" | |
testpath="test/test_${module}*" | |
# Run all tests for "unit" and "python" | |
# Python is the default module for tests | |
if [ "$module" = "unit" ] || [ "$module" = "python" ]; then | |
testpath="test" | |
fi | |
echo "module=${module}" >> "$GITHUB_OUTPUT" | |
echo "version=${version}" >> "$GITHUB_OUTPUT" | |
echo "testpath=${testpath}" >> "$GITHUB_OUTPUT" | |
NJS_VERSION=$(sed -n "s/NJS_VERSION := \(.*\)/\1/p" pkg/contrib/src/njs/version) | |
echo "njs_version=${NJS_VERSION}" >> "$GITHUB_OUTPUT" | |
cat "$GITHUB_OUTPUT" | |
# https://github.com/actions/runner-images/issues/2821 | |
- name: Kill mono process | |
run: | | |
sudo systemctl stop mono-xsp4.service | |
sudo systemctl mask mono-xsp4.service | |
sudo systemctl status mono-xsp4.service || true | |
PID=$(sudo lsof -t -i :8084) | |
echo "Killing PID $PID" | |
sudo kill -9 $PID | |
## | |
## njs | |
## | |
- name: Clone njs repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nginx/njs | |
ref: '${{ steps.metadata.outputs.njs_version }}' | |
path: njs | |
- name: Make njs | |
run: | | |
sudo ./configure --no-libxml2 --no-zlib | |
sudo make -j4 -k | |
working-directory: njs | |
## | |
## Unit | |
## | |
- name: Configure unit | |
run: | | |
sudo ./configure \ | |
--tests \ | |
--openssl \ | |
--njs \ | |
--cc-opt="-I njs/src/ -I njs/build" \ | |
--ld-opt="-L njs/build" | |
- name: Make unit | |
run: | | |
sudo make -j4 -k || sudo make | |
## | |
## Go | |
## | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '${{ steps.metadata.outputs.version }}' | |
cache: false | |
if: steps.metadata.outputs.module == 'go' | |
- name: Configure go | |
run: | | |
sudo ./configure go --go-path= | |
if: steps.metadata.outputs.module == 'go' | |
- name: Make go | |
run: | | |
sudo make go | |
sudo make go-install | |
if: steps.metadata.outputs.module == 'go' | |
## | |
## Java | |
## | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: '${{ steps.metadata.outputs.version }}' | |
if: steps.metadata.outputs.module == 'java' | |
- name: Configure java | |
run: | | |
sudo sudo ./configure java | |
if: steps.metadata.outputs.module == 'java' | |
- name: Make java | |
run: | | |
sudo make java | |
if: steps.metadata.outputs.module == 'java' | |
## | |
## Node | |
## | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '${{ steps.metadata.outputs.version }}' | |
if: steps.metadata.outputs.module == 'node' | |
- name: Install node-gyp | |
run: | | |
sudo npm install -g node-gyp | |
if: steps.metadata.outputs.module == 'node' | |
- name: Configure node | |
run: | | |
sudo ./configure nodejs | |
if: steps.metadata.outputs.module == 'node' | |
- name: Make node | |
run: | | |
sudo make node-local-install DESTDIR=node | |
if: steps.metadata.outputs.module == 'node' | |
## | |
## Perl | |
## | |
# Uses default Actions VM Perl | |
# https://github.com/actions/runner-images#available-images | |
- name: Install libperl-dev | |
run: | | |
sudo apt-get install libperl-dev | |
if: steps.metadata.outputs.module == 'perl' | |
- name: Configure perl | |
run: | | |
sudo ./configure perl | |
if: steps.metadata.outputs.module == 'perl' | |
- name: Make perl | |
run: | | |
sudo make perl | |
if: steps.metadata.outputs.module == 'perl' | |
## | |
## PHP | |
## | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '${{ steps.metadata.outputs.version }}' | |
extensions: none | |
env: | |
update: true | |
if: steps.metadata.outputs.module == 'php' | |
- name: Configure php | |
run: | | |
sudo ./configure php | |
if: steps.metadata.outputs.module == 'php' | |
- name: Make php | |
run: | | |
sudo make php | |
if: steps.metadata.outputs.module == 'php' | |
## | |
## Python 3 | |
## | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '${{ steps.metadata.outputs.version }}' | |
if: steps.metadata.outputs.module == 'python' | |
- name: Configure python3 | |
run: | | |
sudo ./configure python --config=python3-config | |
if: steps.metadata.outputs.module == 'python' | |
- name: Make python3 | |
run: | | |
sudo make python3 | |
if: steps.metadata.outputs.module == 'python' | |
## | |
## Ruby | |
## | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '${{ steps.metadata.outputs.version }}' | |
if: steps.metadata.outputs.module == 'ruby' | |
- name: Install rack | |
run: | | |
sudo gem install rack | |
if: steps.metadata.outputs.module == 'ruby' | |
- name: Configure ruby | |
run: | | |
sudo ./configure ruby | |
if: steps.metadata.outputs.module == 'ruby' | |
- name: Make ruby | |
run: | | |
sudo make ruby | |
if: steps.metadata.outputs.module == 'ruby' | |
## | |
## Wasm | |
## | |
- name: Make wasmtime | |
run: | | |
make -C pkg/contrib .wasmtime | |
if: steps.metadata.outputs.module == 'wasm' | |
- name: Configure wasm | |
run: | | |
sudo ./configure wasm --include-path=pkg/contrib/wasmtime/crates/c-api/include --lib-path=pkg/contrib/wasmtime/target/release | |
if: steps.metadata.outputs.module == 'wasm' | |
- name: Make wasm | |
run: | | |
sudo make wasm | |
if: steps.metadata.outputs.module == 'wasm' | |
## | |
## Tests | |
## | |
# /home/runner will be root only after calling sudo above | |
# Ensure all users and processes can execute | |
- name: Fix permissions | |
run: | | |
sudo chmod -R +x /home/runner | |
namei -l ${{ github.workspace }} | |
# Install python3 if not present | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3' | |
if: steps.metadata.outputs.module != 'wasm' | |
- name: Install pytest | |
run: | | |
sudo -H pip install pytest | |
if: steps.metadata.outputs.module != 'wasm' | |
- name: Run ${{ steps.metadata.outputs.module }} tests | |
run: | | |
sudo -H pytest --print-log ${{ steps.metadata.outputs.testpath }} | |
# Skip pytest if wasm build, as there are no tests yet | |
if: steps.metadata.outputs.module != 'wasm' |