Skip to content

Tests and linting #1036

Tests and linting

Tests and linting #1036

Workflow file for this run

# This workflow will run all tests as well as pre-commit
name: Tests and linting
on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 0 */2 * *"
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
# All of these steps are just setup
- uses: actions/checkout@v3
- name: Setting MAMBA_PATH
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
- name: Setting OPENWPM_MAMBA_PATH
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
# If the environment.yaml hasn't changed we just reuse the entire conda install
- id: cache
uses: actions/cache@v3
env:
cache-name: conda-cache
with:
path: ${{ env.MAMBA_PATH }}
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
- name: Install conda
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
- name: Install.sh (cache miss)
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/install.sh
- name: Install.sh (cache hit)
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
run: $GITHUB_WORKSPACE/install.sh --skip-create
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
# Now we have a working OpenWPM environment
- run: pre-commit run --all
demo:
runs-on: ubuntu-latest
steps:
# All of these steps are just setup
- uses: actions/checkout@v3
- name: Setting MAMBA_PATH
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
- name: Setting OPENWPM_MAMBA_PATH
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
# If the environment.yaml hasn't changed we just reuse the entire conda install
- id: cache
uses: actions/cache@v3
env:
cache-name: conda-cache
with:
path: ${{ env.MAMBA_PATH }}
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
- name: Install conda
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
- name: Install.sh (cache miss)
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/install.sh
- name: Install.sh (cache hit)
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
run: $GITHUB_WORKSPACE/install.sh --skip-create
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
# Now we have a working OpenWPM environment
- run: python demo.py --headless
tests:
runs-on: ubuntu-latest
strategy:
matrix:
test-groups:
[
"test/test_[a-e]*",
"test/test_[f-h]*",
"test/test_[i-o,q-r,t-z]*",
"test/test_[p]*",
"test/test_[s]*",
"test/storage/*",
"test/extension/*",
]
fail-fast: false
steps:
# All of these steps are just setup, maybe we should wrap them in an action
- uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# Setting env variables that depend on $HOME
- name: Setting MAMBA_PATH
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
- name: Setting OPENWPM_MAMBA_PATH
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
# If the environment.yaml hasn't changed we just reuse the entire conda install
- id: conda-cache
uses: actions/cache@v3
env:
cache-name: conda-cache
with:
path: ${{ env.MAMBA_PATH }}
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
- name: Install conda
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
- name: Install.sh (cache miss)
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
run: $GITHUB_WORKSPACE/install.sh
- name: Install.sh (cache hit)
if: ${{ steps.conda-cache.outputs.cache-hit == 'true' }}
run: $GITHUB_WORKSPACE/install.sh --skip-create
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
# Now we have a working OpenWPM environment
- run: ./scripts/ci.sh
env:
DISPLAY: ":99.0"
TESTS: ${{ matrix.test-groups }}
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: ${{matrix.test-groups}} # Name of the check run which will be created
path: junit-report.xml # Path to test results
reporter: java-junit # Format of test results