Skip to content

Commit

Permalink
VPN-5739: MacOS functional testing workflow (#7564)
Browse files Browse the repository at this point in the history
* Add MacOS functional testing in CI
* Generate test addons in the binary dir
* Deprecate generate_all_tests.py script
* Fix cmake build path for wasm
* Remove duplicate addon build during functional tests
* A little bit of test renaming for consistency
* Unify names and style of functional test YAML
* Fix testSettings.js instability on MacOS
* Fix testOnboarding.js instability on MacOS
* Remove generate_all_tests.py script, it is no longer used
* Fix testServers.js instability on MacOS
* Try to get tests to fail faster with a condition timeout
  • Loading branch information
oskirby authored Oct 26, 2023
1 parent b2ed6b4 commit 018a466
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 120 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Functional tests
name: Linux Tests
on:
push:
branches:
Expand Down Expand Up @@ -26,8 +26,10 @@ jobs:
with:
submodules: 'recursive'

- name: Install build dependecies
- name: Install build dependencies
shell: bash
run: |
pip3 install -r requirements.txt
sudo apt-get update
sudo apt-get install -y $(./scripts/linux/getdeps.py -a linux/debian/control)
Expand All @@ -36,20 +38,17 @@ jobs:
uses: actions/cache@v3
with:
path: grcov-build/
key: ${{runner.os}}-grcov-v0.8.13
key: ${{ runner.os }}-grcov-v0.8.13

- name: Install Grcov
if: steps.cache-grcov.outputs.cache-hit != 'true'
shell: bash
run: |
cargo install grcov --root ${{github.workspace}}/grcov-build --version 0.8.13
cargo install grcov --root ${{ github.workspace }}/grcov-build --version 0.8.13
- name: Compile test client
shell: bash
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
pip3 install -r requirements.txt
mkdir -p build/cmake
mkdir -p build/profile
cmake -S $(pwd) -B build/cmake \
Expand All @@ -61,14 +60,7 @@ jobs:
rsync -a --include '*/' --include '*.gcno' --exclude '*' \
build/cmake/tests/dummyvpn/CMakeFiles/dummyvpn.dir/ build/profile/
cp ./build/cmake/tests/dummyvpn/dummyvpn build/
- name: Compile test addons
shell: bash
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
mkdir -p build/addons
cmake -S $(pwd)/tests/functional/addons -B build/addons
cmake --build build/addons
cp -r ./build/cmake/tests/dummyvpn/addons build/addons
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -125,18 +117,18 @@ jobs:
uses: actions/cache@v3
with:
path: grcov-build/
key: ${{runner.os}}-grcov-v0.8.13
key: ${{ runner.os }}-grcov-v0.8.13

- name: Check build
shell: bash
run: |
chmod +x ./build/dummyvpn
./build/dummyvpn -v
chmod +x ${{github.workspace}}/grcov-build/bin/grcov
${{github.workspace}}/grcov-build/bin/grcov --version
chmod +x ${{ github.workspace }}/grcov-build/bin/grcov
${{ github.workspace }}/grcov-build/bin/grcov --version
- name: Running ${{matrix.test.name}} Tests
- name: Running ${{ matrix.test.name }} Tests
id: runTests
uses: nick-invision/retry@v2
with:
Expand All @@ -151,17 +143,16 @@ jobs:
env:
ARTIFACT_DIR: ${{ runner.temp }}/artifacts
MVPN_BIN: ./build/dummyvpn
MVPN_ADDONS_PATH: ./build/addons

- name: Generating grcov reports
id: generateGrcov
continue-on-error: true # Ignore GRCOV parsing errors, see github.com/mozilla/grcov/issues/570
timeout-minutes: 1 # Give GRCOV a short timeout in case it hangs after a panic
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
export PATH=${{ github.workspace }}/grcov-build/bin:$PATH
grcov build/profile \
-s src -t lcov --branch --ignore-not-existing \
-o ${{runner.temp}}/artifacts/functional_lcov.info
-o ${{ runner.temp }}/artifacts/functional_lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand All @@ -170,12 +161,12 @@ jobs:
directory: .
flags: functional_tests
name: codecov-poc
files: ${{runner.temp}}/artifacts/functional_lcov.info
files: ${{ runner.temp }}/artifacts/functional_lcov.info
verbose: true

- name: Uploading artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: ${{matrix.test.name}} Logs
name: ${{ matrix.test.name }} Logs
path: ${{ runner.temp }}/artifacts
125 changes: 125 additions & 0 deletions .github/workflows/macos_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: MacOS Tests
on:
push:
branches:
- main
- "releases/**"
pull_request:
branches:
- main
- "releases/**"

# Restrict tests to the most recent commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_test_app:
name: Build Test Client
runs-on: macos-latest
outputs:
matrix: ${{ steps.testGen.outputs.tests }}
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install build dependencies
shell: bash
run: |
pip3 install -r requirements.txt
brew install ninja
- name: Install Qt6
shell: bash
run: |
wget https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/mozillavpn.v2.mozillavpn.cache.level-3.toolchains.v3.qt-mac.latest/artifacts/public%2Fbuild%2Fqt6_mac.zip -O qt6_mac.zip
unzip -a -d ${{ github.workspace }} qt6_mac.zip
- name: Compile test client
shell: bash
run: |
mkdir -p build/cmake
cmake -S $(pwd) -B build/cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/qt_dist/lib/cmake
cmake --build build/cmake -j$(nproc) --target dummyvpn
cp ./build/cmake/tests/dummyvpn/dummyvpn build/
cp -r ./build/cmake/tests/dummyvpn/addons build/addons
- uses: actions/upload-artifact@v3
with:
name: test-client-${{ github.sha }}
path: |
build/
!build/cmake/
- name: Generate tasklist
id: testGen
shell: bash
run: |
echo -n "tests=" >> $GITHUB_OUTPUT
for test in $(find tests/functional -name 'test*.js' | sort); do
printf '{"name": "%s", "path": "%s"}' $(basename ${test%.js} | sed -n 's/test//p') $test
done | jq -s -c >> $GITHUB_OUTPUT
- name: Check tests
shell: bash
env:
TEST_LIST: ${{ steps.testGen.outputs.tests }}
run: |
echo $TEST_LIST | jq
functionaltests:
name: Functional tests
needs:
- build_test_app
runs-on: macos-latest
timeout-minutes: 45
strategy:
fail-fast: false # Don't cancel other jobs if a test fails
matrix:
test: ${{ fromJson(needs.build_test_app.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: test-client-${{ github.sha }}
path: build/

- name: Install test dependecies
run: |
pip3 install -r requirements.txt
npm install
- name: Check build
shell: bash
run: |
chmod +x ./build/dummyvpn
./build/dummyvpn -v
- name: Running ${{ matrix.test.name }} Tests
id: runTests
uses: nick-invision/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: |
export PATH=$GECKOWEBDRIVER:$(npm bin):$PATH
export HEADLESS=yes
export TZ=Europe/London
mkdir -p $ARTIFACT_DIR
npm run functionalTest -- --retries 3 ${{ matrix.test.path }}
env:
ARTIFACT_DIR: ${{ runner.temp }}/artifacts
MVPN_BIN: ./build/dummyvpn

- name: Uploading artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: ${{ matrix.test.name }} Logs
path: ${{ runner.temp }}/artifacts
86 changes: 40 additions & 46 deletions .github/workflows/wasm.yaml → .github/workflows/wasm_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: WebAssembly

name: WebAssembly Tests
on:
push:
branches:
- main
- 'releases/**'
- "releases/**"
pull_request:
branches:
- main
- 'releases/**'
- "releases/**"

# Restrict tests to the most recent commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -27,31 +27,49 @@ jobs:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'true'

- name: Install Qt
- name: Install build dependencies
shell: bash
run: |
pip3 install -r requirements.txt
- name: Install Qt6
shell: bash
run: |
python3 -m pip install aqtinstall
# qt6.2.3 for wasm needs the desktop linux installation
python3 -m aqt install-qt -O /opt linux desktop $QTVERSION
python3 -m aqt install-qt -O /opt linux desktop $QTVERSION wasm_32 -m qtcharts qtwebsockets qt5compat
- name: Install python dependencies
shell: bash
run: |
pip install -r requirements.txt
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v7

- name: Compiling
- name: Compile test client
shell: bash
run: |
export PATH=/opt/$QTVERSION/wasm_32/bin:/opt/$QTVERSION/gcc_64/bin:$PATH
mkdir build
/opt/$QTVERSION/wasm_32/bin/qt-cmake -S . -B build -DQT_HOST_PATH=/opt/$QTVERSION/gcc_64 -DQT_HOST_PATH_CMAKE_DIR=/opt/$QTVERSION/gcc_64/lib/cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build -j4
mkdir -p build/cmake
/opt/$QTVERSION/wasm_32/bin/qt-cmake -S $(pwd) -B build/cmake -DCMAKE_BUILD_TYPE=Release \
-DQT_HOST_PATH_CMAKE_DIR=/opt/$QTVERSION/gcc_64/lib/cmake \
-DQT_HOST_PATH=/opt/$QTVERSION/gcc_64
cmake --build build/cmake -j4
cp -r build/cmake/wasm_build build/wasm_build
- name: Compile test addons
shell: bash
run: |
mkdir -p build/addons
cmake -S $(pwd)/tests/functional/addons -B build/addons \
-DCMAKE_PREFIX_PATH=/opt/$QTVERSION/gcc_64/lib/cmake
cmake --build build/addons
- uses: actions/upload-artifact@v3
with:
name: WebAssembly Build Qt6
path: |
build/
!build/cmake/
- name: Generate tasklist
id: testGen
Expand All @@ -69,12 +87,6 @@ jobs:
run: |
echo $TEST_LIST | jq
- name: Uploading
uses: actions/upload-artifact@v3
with:
name: WebAssembly Build Qt6
path: build/wasm_build

functionaltests:
name: Functional tests
needs:
Expand All @@ -92,37 +104,18 @@ jobs:
- name: Clone repository
uses: actions/checkout@v3

- name: Cache build
id: cache-build
uses: actions/cache@v3
- uses: actions/download-artifact@v3
with:
name: WebAssembly Build Qt6
path: build/
key: ${{ github.sha }}

- name: Install Qt
shell: bash
run: |
python3 -m pip install aqtinstall
python3 -m aqt install-qt -O /opt linux desktop $QTVERSION
- name: Install dependecies
- name: Install test dependecies
run: |
sudo apt install --no-upgrade firefox xvfb -y
pip3 install -r requirements.txt
npm install
- name: Download a Build Artifact
uses: actions/download-artifact@v3
with:
name: WebAssembly Build Qt6
# Destination path, WASM_BUILD_DIRECTORY
path: wasm_build

- name: Build addons
shell: bash
run: ./scripts/addon/generate_all_tests.py -q /opt/$QTVERSION/gcc_64/bin

- name: Running ${{matrix.test.name}} Tests
- name: Running ${{ matrix.test.name }} Tests
id: runTests
uses: nick-invision/retry@v2
with:
Expand All @@ -131,5 +124,6 @@ jobs:
command: |
export PATH=$GECKOWEBDRIVER:$(npm bin):$PATH
export HEADLESS=yes
export WASM_BUILD_DIRECTORY=$(pwd)/wasm_build
xvfb-run -a npm run functionalTestWasm -- --retries 3 ${{matrix.test.path}}
export WASM_BUILD_DIRECTORY=$(pwd)/build/wasm_build
export MVPN_ADDONS_PATH=$(pwd)/build/addons
xvfb-run -a npm run functionalTestWasm -- --retries 3 ${{ matrix.test.path }}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export MVPN_BIN=$(pwd)/build/tests/dummyvpn/dummyvpn
**Other dependencies**:
* Install node (if needed) and then `npm install` to install the testing
dependencies
* Compile the testing addons: `./scripts/addon/generate_all_tests.py`
* Make a .env file and place it in the root folder for the repo. It should include:
* `MVPN_BIN` (location of compiled mvpn binary. This must be a dummy binary, see note above.)
* `ARTIFACT_DIR` - optional (directory to put screenshots from test failures)
Expand Down
Loading

0 comments on commit 018a466

Please sign in to comment.