From eb2167f278519301ffee541a35b4f9b60854b542 Mon Sep 17 00:00:00 2001 From: Iurii Kondrakov Date: Tue, 26 Nov 2024 16:30:57 -0500 Subject: [PATCH 1/2] Introduce TICS workflow (#46) --- .github/workflows/tics.yaml | 63 +++++++++++++++++++++++++++++++++++++ tox.ini | 11 ++++++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tics.yaml diff --git a/.github/workflows/tics.yaml b/.github/workflows/tics.yaml new file mode 100644 index 0000000..dadb089 --- /dev/null +++ b/.github/workflows/tics.yaml @@ -0,0 +1,63 @@ +name: TICS + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Verify snap builds successfully + id: build + uses: canonical/action-build@v1 + + - name: Upload the built snap + uses: actions/upload-artifact@v4 + with: + name: snap_artifact + path: ${{ steps.build.outputs.snap }} + + tics-report: + needs: build + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + sudo apt update + python -m pip install --upgrade pip + # tics action requires flake8 to be installed on the runner + # https://github.com/tiobe/tics-github-action/issues/410 + python -m pip install flake8 + # pin tox to the current major version to avoid + # workflows breaking all at once when a new major version is released. + python -m pip install 'tox<5' + + - name: Get the snap artifact + uses: actions/download-artifact@v4 + with: + name: snap_artifact + + - name: Test with tox and produce coverage report + run: tox -e tics + + - name: Run TICS analysis + uses: tiobe/tics-github-action@v3 + with: + mode: qserver + project: dcgm-snap + viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default + branchdir: ${{ github.workspace }} + ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }} + installTics: true diff --git a/tox.ini b/tox.ini index 35f1e7a..769a542 100644 --- a/tox.ini +++ b/tox.ini @@ -26,12 +26,21 @@ deps = {[testenv:func]deps} [testenv:reformat] -envdir = {toxworkdir}/lint deps = {[testenv:lint]deps} commands = black . isort . +[testenv:tics] +base = testenv +deps = + pytest + pytest-cov +description = Run all tests for snap and produce coverage report +commands = + pytest {toxinidir}/tests \ + -v --cov --cov-report=xml:{toxinidir}/tests/report/coverage.xml --junit-xml={toxinidir}/tests/report/tests.xml + [testenv:func] deps = pytest From a75e57783343f80eec9efa14cefc9bef041419d6 Mon Sep 17 00:00:00 2001 From: Iurii Kondrakov Date: Wed, 27 Nov 2024 15:31:50 -0500 Subject: [PATCH 2/2] Add tics target dependancies (#47) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 769a542..6e356cd 100644 --- a/tox.ini +++ b/tox.ini @@ -32,10 +32,10 @@ commands = isort . [testenv:tics] -base = testenv deps = pytest pytest-cov + -r {toxinidir}/tests/functional/requirements.txt description = Run all tests for snap and produce coverage report commands = pytest {toxinidir}/tests \