diff --git a/.github/workflows/auth_tests.yml b/.github/workflows/auth_tests.yml new file mode 100644 index 0000000000..412dacea44 --- /dev/null +++ b/.github/workflows/auth_tests.yml @@ -0,0 +1,129 @@ +name: Auth Tests +on: + # Only run on push to main or release branches. + push: + branches: + - main + - "releases/**" + +# Restrict tests to the most recent commit. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + linux-unit-tests: + runs-on: ubuntu-22.04 + name: Run auth tests on Linux + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Install dependences + run: | + sudo apt-get update + sudo apt-get install -y $(./scripts/linux/getdeps.py -a linux/debian/control) + pip3 install -r requirements.txt + + - name: Building tests + shell: bash + run: | + mkdir -p build + cmake -S . -B $(pwd)/build \ + -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage + cmake --build $(pwd)/build --target app_auth_tests -j$(nproc) + + - name: Running tests + shell: bash + working-directory: ./build/tests/auth_tests + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --output-on-failure + + macos-unit-tests: + runs-on: macos-latest + name: Run auth tests on MacOS + + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Install 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 mac.zip + unzip -a mac.zip + sudo mv qt_dist /opt + cd .. + + - 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 + + - name: Building tests + shell: bash + run: | + export PATH=/opt/qt_dist/bin:${{github.workspace}}/grcov-build/bin:$PATH + mkdir -p build + cmake -S . -B $(pwd)/build -GNinja \ + -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage + cmake --build $(pwd)/build --target app_auth_tests + + - name: Running tests + shell: bash + working-directory: ./build/tests/auth_tests + run: | + export PATH=/opt/qt_dist/bin:${{github.workspace}}/grcov-build/bin:$PATH + ctest --output-on-failure + + windows-unit-tests: + name: Run auth tests on Windows + runs-on: windows-latest + + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Install Qt + shell: pwsh + run: | + Invoke-WebRequest -Uri https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/mozillavpn.v2.mozillavpn.cache.level-3.toolchains.v3.qt-win.latest/artifacts/public%2Fbuild%2Fqt6_win.zip -OutFile win.zip + Expand-Archive win.zip + mv win\QT_OUT "C:\\MozillaVPNBuild" + + - name: Add msvc dev commands to PATH + uses: ilammy/msvc-dev-cmd@v1 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Install depedencies + shell: bash + run: | + pip3 install -r requirements.txt + + - name: Building tests + run: | + mkdir ./build + cmake -S . -B ./build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="C:\MozillaVPNBuild\lib\cmake" + cmake --build ./build --target app_auth_tests + + - name: Running tests + shell: bash + working-directory: ./build/tests/auth_tests + run: | + ctest --output-on-failure diff --git a/.github/workflows/test_unit.yaml b/.github/workflows/test_unit.yaml index cd4e1341b8..fe1cac45f7 100644 --- a/.github/workflows/test_unit.yaml +++ b/.github/workflows/test_unit.yaml @@ -22,7 +22,7 @@ jobs: - name: Clone repository uses: actions/checkout@v3 with: - submodules: 'recursive' + submodules: "recursive" - name: Install dependences run: | @@ -51,26 +51,38 @@ jobs: -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage cmake --build $(pwd)/build --target build_tests -j$(nproc) - - name: Running tests + - name: Running native messaging tests shell: bash - working-directory: ./build + working-directory: ./build/tests/nativemessaging run: | export PATH=${{github.workspace}}/grcov-build/bin:$PATH ctest --output-on-failure - grcov $(pwd)/tests/nativemessaging/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \ + grcov $(pwd)/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/nativemessaging_lcov.info - grcov $(pwd)/tests/qml/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \ + - name: Running QML tests + shell: bash + working-directory: ./build/tests/qml + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --output-on-failure + + grcov $(pwd)/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/qml_lcov.info - grcov $(pwd)/tests/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \ - -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info + - name: Running unit tests + shell: bash + working-directory: ./build/tests + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --test-dir unit --output-on-failure + ctest --test-dir unit_tests --output-on-failure - grcov $(pwd)/tests/auth_tests/CMakeFiles/app_auth_tests.dir -s ${{github.workspace}} \ - -t lcov --branch --ignore-not-existing > ${{github.workspace}}/auth_lcov.info + grcov $(pwd)/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \ + -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info - grcov $(pwd)/tests/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \ + grcov $(pwd)/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unitapp_lcov.info - name: Upload coverage for linux unit tests to Codecov @@ -79,7 +91,7 @@ jobs: directory: . flags: linux_unit_tests name: codecov-poc - files: auth_lcov.info,nativemessaging_lcov.info,qml_lcov.info,unit_lcov.info,unitapp_lcov.info + files: nativemessaging_lcov.info,qml_lcov.info,unit_lcov.info,unitapp_lcov.info verbose: true macos-unit-tests: @@ -90,7 +102,7 @@ jobs: - name: Clone repository uses: actions/checkout@v3 with: - submodules: 'recursive' + submodules: "recursive" - name: Install dependencies shell: bash @@ -128,26 +140,38 @@ jobs: -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage cmake --build $(pwd)/build --target build_tests - - name: Running tests + - name: Running native messaging tests shell: bash - working-directory: ./build + working-directory: ./build/tests/nativemessaging run: | - export PATH=/opt/qt_dist/bin:${{github.workspace}}/grcov-build/bin:$PATH + export PATH=${{github.workspace}}/grcov-build/bin:$PATH ctest --output-on-failure - grcov $(pwd)/tests/nativemessaging/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \ + grcov $(pwd)/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/nativemessaging_lcov.info - grcov $(pwd)/tests/qml/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \ + - name: Running QML tests + shell: bash + working-directory: ./build/tests/qml + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --output-on-failure + + grcov $(pwd)/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/qml_lcov.info - grcov $(pwd)/tests/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \ - -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info + - name: Running unit tests + shell: bash + working-directory: ./build/tests + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --test-dir unit --output-on-failure + ctest --test-dir unit_tests --output-on-failure - grcov $(pwd)/tests/auth_tests/CMakeFiles/app_auth_tests.dir -s ${{github.workspace}} \ - -t lcov --branch --ignore-not-existing > ${{github.workspace}}/auth_lcov.info + grcov $(pwd)/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \ + -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info - grcov $(pwd)/tests/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \ + grcov $(pwd)/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \ -t lcov --branch --ignore-not-existing > ${{github.workspace}}/unitapp_lcov.info - name: Upload coverage for macos unit tests to Codecov @@ -167,7 +191,7 @@ jobs: - name: Clone repository uses: actions/checkout@v3 with: - submodules: 'recursive' + submodules: "recursive" - name: Install Qt shell: pwsh @@ -175,7 +199,7 @@ jobs: Invoke-WebRequest -Uri https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/mozillavpn.v2.mozillavpn.cache.level-3.toolchains.v3.qt-win.latest/artifacts/public%2Fbuild%2Fqt6_win.zip -OutFile win.zip Expand-Archive win.zip mv win\QT_OUT "C:\\MozillaVPNBuild" - + - name: Add msvc dev commands to PATH uses: ilammy/msvc-dev-cmd@v1 @@ -193,8 +217,24 @@ jobs: cmake -S . -B ./build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="C:\MozillaVPNBuild\lib\cmake" cmake --build ./build --target build_tests - - name: Running tests + - name: Running native messaging tests shell: bash - working-directory: ./build + working-directory: ./build/tests/nativemessaging run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH ctest --output-on-failure + + - name: Running QML tests + shell: bash + working-directory: ./build/tests/qml + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --output-on-failure + + - name: Running unit tests + shell: bash + working-directory: ./build/tests + run: | + export PATH=${{github.workspace}}/grcov-build/bin:$PATH + ctest --test-dir unit --output-on-failure + ctest --test-dir unit_tests --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index e1212412f7..fcc6cb5b3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,9 +155,11 @@ if(NOT CMAKE_CROSSCOMPILING) add_subdirectory(tests/nativemessaging EXCLUDE_FROM_ALL) add_subdirectory(tests/unit EXCLUDE_FROM_ALL) add_subdirectory(tests/qml EXCLUDE_FROM_ALL) - add_subdirectory(tests/auth_tests EXCLUDE_FROM_ALL) add_subdirectory(tests/unit_tests EXCLUDE_FROM_ALL) + # E2E Tests + add_subdirectory(tests/auth_tests EXCLUDE_FROM_ALL) + # Dummy Testing Client add_subdirectory(tests/dummyvpn EXCLUDE_FROM_ALL) endif()