From 3573926eec07eba6f0f077c6d396323007112fd7 Mon Sep 17 00:00:00 2001 From: Clyde Johnston Date: Thu, 17 Aug 2023 23:59:55 +0000 Subject: [PATCH] Added SONAR and COVERALLS tokens to environment for nox job --- .github/workflows/test-and-release.yml | 8 ++++++-- noxfile.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 22b69005..76ea194e 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-2019-npcap] - python: ['3.7', '3.8', '3.9', '3.10'] + os: [ ubuntu-20.04, windows-2019-npcap ] + python: [ '3.7', '3.8', '3.9', '3.10' ] runs-on: ${{ matrix.os }} steps: - name: Check out @@ -52,6 +52,10 @@ jobs: run: | nox --non-interactive --error-on-missing-interpreters --session test pristine --python ${{ matrix.python }} nox --non-interactive --session demo check_style docs + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Save logs uses: actions/upload-artifact@v3 diff --git a/noxfile.py b/noxfile.py index 6c8dd888..98cfe367 100644 --- a/noxfile.py +++ b/noxfile.py @@ -133,14 +133,21 @@ def test(session): session.run("pylint", *map(str, src_dirs), env={"PYTHONPATH": str(compiled_dir)}) # Publish coverage statistics. This also has to be run from the test session to access the coverage files. + coveralls_repo_token = session.env.get("COVERALLS_REPO_TOKEN") + github_token = session.env.get("GITHUB_TOKEN") + github_actions = session.env.get("GITHUB_ACTIONS") if sys.platform.startswith("linux") and is_latest_python(session) and session.env.get("COVERALLS_REPO_TOKEN"): session.install("coveralls") - session.run("coveralls") + session.run("echo", "GITHUB_ACTIONS", "$GITHUB_ACTIONS", "---", env={"GITHUB_ACTIONS": f"{github_actions}"}, external=True) + session.run("echo", "GITHUB_ACTIONS", "$GITHUB_ACTIONS", "---", external=True) + session.run("echo", "COVERALLS_SKIP_SSL_VERIFY", "$COVERALLS_SKIP_SSL_VERIFY", "---", external=True) + session.run("coveralls", "--verbose", env={"GITHUB_TOKEN": f"{github_token}", "GITHUB_ACTIONS": f"{github_actions}"}) + # session.run("coveralls", "--service=github", env={"GITHUB_TOKEN": f"{github_token}", "GITHUB_ACTIONS": f"{github_actions}"}) else: session.log("Coveralls skipped") # Submit analysis to SonarCloud. This also has to be run from the test session to access the coverage files. - sonarcloud_token = session.env.get("SONARCLOUD_TOKEN") + sonarcloud_token = session.env.get("SONAR_TOKEN") if sys.platform.startswith("linux") and is_latest_python(session) and sonarcloud_token: session.run("coverage", "xml", "-i", "-o", str(ROOT_DIR / ".coverage.xml"))