From 8032ce31e37107ea538ebb50b7e792cf5fd3fe21 Mon Sep 17 00:00:00 2001 From: Dylan Arbour Date: Tue, 27 Feb 2024 09:41:07 -0500 Subject: Test with root access in GitHub workflows To enable tests that require privileged root access, this commit tests with `sudo`. The Java and Python jobs have additional permissions issues, so they are also configured and made with `sudo`. A small permissions fix is required before running tests to allow non-root users to execute within the `/home/runner` directory. This change also removes the custom directories that were required without root access. Reviewed-by: Andrew Clayton Signed-off-by: Dylan Arbour --- .github/workflows/ci.yml | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5368ae9..d5a2529b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,22 +53,6 @@ jobs: steps: - uses: actions/checkout@v4 - # Creates and outputs directories used by tests (/usr/local is unfriendly) - - name: Configure directories - id: dir - run: | - PREFIX=${HOME}/.unit - BIN=${PREFIX}/bin - VAR=${PREFIX}/var - mkdir -p $BIN - mkdir -p $VAR - - echo "prefix=${PREFIX}" >> "$GITHUB_OUTPUT" - echo "bin=${BIN}" >> "$GITHUB_OUTPUT" - echo "bin=${BIN}" >> "$GITHUB_PATH" - echo "var=${VAR}" >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" - # Provides module, language version and testpath from build name - name: Output build metadata id: metadata @@ -127,15 +111,6 @@ jobs: - name: Configure unit run: | ./configure \ - --prefix=${{ steps.dir.outputs.prefix }} \ - --sbindir=${{ steps.dir.outputs.bin }} \ - --logdir=${{ steps.dir.outputs.var }}/log \ - --log=${{ steps.dir.outputs.var }}/log/unit/unit.log \ - --runstatedir=${{ steps.dir.outputs.var }}/run \ - --pid=${{ steps.dir.outputs.var }}/run/unit/unit.pid \ - --control=unix:${{ steps.dir.outputs.var }}/run/unit/control.sock \ - --modules=${{ steps.dir.outputs.prefix }}/lib/unit/modules \ - --statedir=${{ steps.dir.outputs.var }}/state/unit \ --tests \ --openssl \ --njs \ @@ -179,12 +154,12 @@ jobs: - name: Configure java run: | - ./configure java + sudo ./configure java if: steps.metadata.outputs.module == 'java' - name: Make java run: | - make java + sudo make java if: steps.metadata.outputs.module == 'java' ## @@ -266,12 +241,12 @@ jobs: - name: Configure python3 run: | - ./configure python --config=python3-config + sudo ./configure python --config=python3-config if: steps.metadata.outputs.module == 'python' - name: Make python3 run: | - make python3 + sudo make python3 if: steps.metadata.outputs.module == 'python' ## @@ -321,6 +296,13 @@ jobs: ## 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: @@ -329,11 +311,11 @@ jobs: - name: Install pytest run: | - pip install pytest + sudo -H pip install pytest if: steps.metadata.outputs.module != 'wasm' - name: Run ${{ steps.metadata.outputs.module }} tests run: | - pytest --print-log ${{ steps.metadata.outputs.testpath }} + sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} # Skip pytest if wasm build, as there are no tests yet if: steps.metadata.outputs.module != 'wasm' -- cgit From 0cee7d1a481abef182655425c927e903df0ba4c2 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Wed, 6 Mar 2024 00:02:51 +0000 Subject: Add GitHub workflow for wasm-wasi-component This adds a GitHub CI workflow for the new wasm-wasi-component language module. Some things of note. 1) We need to special case 'wasm-wasi-component' in the 'Output build metadata' section as we are splitting the module names on '-' to split them into name and version. 2) Apart from needing to tell bindgen about the njs include paths, we also need to explicitly specify which version of clang to use to work around an issue with multiple versions of clang installed. Link: Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5a2529b..4de8a3b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,8 @@ jobs: os: ubuntu-latest - build: wasm os: ubuntu-latest + - build: wasm-wasi-component + os: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -57,8 +59,12 @@ jobs: - name: Output build metadata id: metadata run: | - # Split the build name by '-' into module and version - IFS='-' read -r module version <<< "${{ matrix.build }}" + if [ "${{ matrix.build }}" = "wasm-wasi-component" ]; then + module="wasm-wasi-component" + else + # Split the build name by '-' into module and version + IFS='-' read -r module version <<< "${{ matrix.build }}" + fi testpath="test/test_${module}*" @@ -292,6 +298,27 @@ jobs: make wasm if: steps.metadata.outputs.module == 'wasm' + ## + ## wasm-wasi-component + ## + + - name: Setup rust + run: | + curl https://sh.rustup.rs | sh -s -- -y + if: steps.metadata.outputs.module == 'wasm-wasi-component' + + - name: Configure wasm-wasi-component + run: | + ./configure wasm-wasi-component + if: steps.metadata.outputs.module == 'wasm-wasi-component' + + - name: Make wasm-wasi-component + run: | + CLANG_PATH=/usr/bin/clang-15 \ + BINDGEN_EXTRA_CLANG_ARGS="-I../../njs/src -I../../njs/build" \ + make wasm-wasi-component + if: steps.metadata.outputs.module == 'wasm-wasi-component' + ## ## Tests ## @@ -307,15 +334,18 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3' - if: steps.metadata.outputs.module != 'wasm' + if: steps.metadata.outputs.module != 'wasm' && + steps.metadata.outputs.module != 'wasm-wasi-component' - name: Install pytest run: | sudo -H pip install pytest - if: steps.metadata.outputs.module != 'wasm' + if: steps.metadata.outputs.module != 'wasm' && + steps.metadata.outputs.module != 'wasm-wasi-component' - name: Run ${{ steps.metadata.outputs.module }} tests run: | sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} # Skip pytest if wasm build, as there are no tests yet - if: steps.metadata.outputs.module != 'wasm' + if: steps.metadata.outputs.module != 'wasm' && + steps.metadata.outputs.module != 'wasm-wasi-component' -- cgit From 4fc50258b57f90fa9b40ca50c24af815625ed343 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Fri, 17 May 2024 16:01:25 +0100 Subject: ci: Be more specific when to run the main Unit checks ci-dev-distro-compiler.yaml already limits itself to running only when relevant things are updated. Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4de8a3b6..acb2b9f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,14 @@ name: ci on: pull_request: push: - branches: - - master + branches: master + paths: + - configure + - 'auto/**' + - 'go/**' + - 'src/**' + - 'test/**' + - '.github/workflows/ci.yml' jobs: test: -- cgit From d7ec30c43aea185a8425e8c2ba3a6fbfdd24282b Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 6 Jun 2024 23:45:05 +0100 Subject: ci: Limit when to run checks on pull-requests Commit 4fc50258b ("ci: Be more specific when to run the main Unit checks") limited when the checks for the main ci run, on pushes to master. It should have done the same for pull-requests. Fixes: 4fc50258b ("ci: Be more specific when to run the main Unit checks") Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb2b9f8..541b7201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,13 @@ name: ci on: pull_request: + paths: + - configure + - 'auto/**' + - 'go/**' + - 'src/**' + - 'test/**' + - '.github/workflows/ci.yml' push: branches: master paths: -- cgit From 337cba43a5b74922bb38992ed09d3ddfe673e5e7 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 26 Aug 2024 15:35:48 +0100 Subject: ci: Enable the wasm-wasi-component tests We now have tests for this module via commit cad6aed52 ("Tests: initial "wasm-wasi-component" test"). We need to install cargo-component for this test target. Also the only way I found I could get this test to run was by running as non-root. The issue I was seeing was that despite cargo being installed into /home/runner/.cargo/bin *and* that being in the path, it kept claiming it couldn't find cargo. E.g. $ sudo -E echo $PATH Showed /home/runner/.cargo/bin in there. $ sudo -E /home/runner/.cargo/bin/cargo -V Worked. $ sudo -E cargo -V cargo command not found. (Also other oddities, despite claiming to be using bash, it couldn't find shell builtins like 'hash' and 'export', perhaps some Ubuntu weirdness...) However, no problem, there is *no* need for it run as root anyway so result! Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 541b7201..47dd0af3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -318,6 +318,7 @@ jobs: - name: Setup rust run: | curl https://sh.rustup.rs | sh -s -- -y + cargo install cargo-component if: steps.metadata.outputs.module == 'wasm-wasi-component' - name: Configure wasm-wasi-component @@ -347,18 +348,22 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3' - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if: steps.metadata.outputs.module != 'wasm' - name: Install pytest run: | - sudo -H pip install pytest - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if [ "${{ matrix.build }}" == "wasm-wasi-component" ]; then + pip install pytest + else + sudo -H pip install pytest + fi + if: steps.metadata.outputs.module != 'wasm' - name: Run ${{ steps.metadata.outputs.module }} tests run: | - sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} - # Skip pytest if wasm build, as there are no tests yet - if: steps.metadata.outputs.module != 'wasm' && - steps.metadata.outputs.module != 'wasm-wasi-component' + if [ "${{ matrix.build }}" == "wasm-wasi-component" ]; then + pytest --print-log ${{ steps.metadata.outputs.testpath }} + else + sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }} + fi + if: steps.metadata.outputs.module != 'wasm' -- cgit From c5846ba3cd13b64516e1dad0df73d5fb8cee9d60 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 9 Sep 2024 22:36:34 +0100 Subject: ci: Fix wasmtime paths in ci.yml With commit 9998918db ("Packages: bump wasmtime to 24.0.0 and wasi-sysroot to 24.0.") the paths to the wasmtime C API include and lib directories changed which broke the wasm ci tests. Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47dd0af3..69691489 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -303,7 +303,7 @@ jobs: - name: Configure wasm run: | - ./configure wasm --include-path=pkg/contrib/wasmtime/crates/c-api/include --lib-path=pkg/contrib/wasmtime/target/release + ./configure wasm --include-path=pkg/contrib/wasmtime/artifacts/include --lib-path=pkg/contrib/wasmtime/artifacts/lib if: steps.metadata.outputs.module == 'wasm' - name: Make wasm -- cgit From 46ddb010379862b108879c471760252ad9bb3ad7 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 9 Sep 2024 22:50:11 +0100 Subject: ci: Trigger ci.yml for changes under pkg/contrib This will catch changes to the likes of wasmtime and njs. Signed-off-by: Andrew Clayton --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69691489..0f9bc699 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: - 'go/**' - 'src/**' - 'test/**' + - 'pkg/contrib/**' - '.github/workflows/ci.yml' push: branches: master @@ -17,6 +18,7 @@ on: - 'go/**' - 'src/**' - 'test/**' + - 'pkg/contrib/**' - '.github/workflows/ci.yml' jobs: -- cgit