-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Remove build CI maven (in favor of Poetry) and synchronise rele…
…ase workflow (#41) * Remove maven. Add pyproject.toml and unittest workflow * add base release.yml template * remove all trigger from main.yml * fix requirement export * add trigger constains to unittests workflwo * fix poetry dep group spelling * add sonar-project.properties * temporary remove sonar-cloud scan * rename sonar token * rename sonar token v2 * add coverage rc configuration and release workflow * add sonarqube quality gate * add branch to coveragerc * test simplify properties * rollback * update sonar cloud token name * Change test run * Fix sonar token env * Run unittests against branches * Remove tox * test v2 * run sonar with verbosity * run sonar with verbosity v2 * Save test results * Trigger from editing code * Add python multi-version tests * try tox-gh plugin * Add verbosity to tox * Limit tests to v3.11 for the moment * Remove tox and add multi version testing using poetry * Fix conditional steps * Move the trigger to pull requests * Add both master and main as release trigger branches * fix bug on trigger by push * remove support for py3.8 * extract release workflow python version from pyproject.toml * test release workflow * test release workflow v2 * test release workflow v2 * remove 3.8 form unittests * add repo level variables to unittests * add repo level variables to unittests v2 * add latest extraction * fix latest version extraction * fix latest version extraction v2 * fix latest version extraction v3 * fix latest version extraction v4 * fix latest version extraction v5 * fix latest version extraction v6 * fix latest version extraction v7 * fix latest version extraction v8 * extracting latest WiP almost there * add dynamic sonar python version * remove python version from properties * update README.md to align with new workflow name --------- Co-authored-by: Nacho <nacho@sixsq.com>
- Loading branch information
1 parent
105de9b
commit 7e50d70
Showing
67 changed files
with
822 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[run] | ||
relative_files = True | ||
source = nuvla | ||
omit = | ||
tests/* | ||
branch = True | ||
|
||
[report] | ||
exclude_also = | ||
; Don't complain if non-runnable code isn't run: | ||
if 0: | ||
if __name__ == .__main__.: | ||
|
||
; Don't complain about abstract methods, they aren't run: | ||
@(abc\.)?abstractmethod | ||
from .* import .* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "3.0.9" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"release-type": "python", | ||
"include-v-in-tag": false, | ||
|
||
"packages": { | ||
".": { | ||
"release-type": "python", | ||
"include-v-in-tag": false | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: "Release" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
trigger-release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
major: ${{ steps.release.outputs.major }} | ||
minor: ${{ steps.release.outputs.minor }} | ||
patch: ${{ steps.release.outputs.patch }} | ||
tag_name: ${{ steps.release.outputs.tag_name }} | ||
|
||
steps: | ||
- id: release | ||
uses: google-github-actions/release-please-action@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
target-branch: ${{ github.ref_name }} | ||
config-file: .github/release-please-config.json | ||
manifest-file: .github/.release-please-manifest.json | ||
|
||
publish-release: | ||
name: "Publish package to GitHub and PyPi release" | ||
needs: trigger-release | ||
if: needs.trigger-release.outputs.release_created | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: 'pyproject.toml' | ||
|
||
- name: Print python version | ||
run: python --version | ||
|
||
- name: Load cached Poetry installation | ||
id: cached-poetry | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.local # the path depends on the OS | ||
key: poetry-0 # increment to reset cache | ||
|
||
- name: Setup Poetry | ||
uses: snok/install-poetry@v1 | ||
if: steps.cached-poetry.outputs.cache-hit != 'true' | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Build Package | ||
run: | | ||
poetry build --no-interaction --format=wheel | ||
- name: Add artifacts to release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "Uploading artifacts to release ${{ needs.trigger-release.outputs.tag_name }}" | ||
gh release upload ${{ needs.trigger-release.outputs.tag_name }} ./dist/*.whl | ||
- name: Publish package to PyPi | ||
run: | | ||
poetry config repositories.nuvla-api https://pypi.org/project/nuvla-api/ | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish | ||
job-notify: | ||
if: needs.trigger-release.outputs.release_created | ||
name: Post Workflow Status To Slack | ||
needs: publish-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: Gamesight/slack-workflow-status@master | ||
with: | ||
repo_token: ${{secrets.GITHUB_TOKEN}} | ||
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: "UnitTests" | ||
|
||
on: | ||
# add push to main trigger for sonarcloud scan | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
|
||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "nuvla/**" | ||
- "tests/**" | ||
- ".github/workflows/unittest.yml" | ||
|
||
|
||
|
||
jobs: | ||
setup-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
versions: ${{ steps.set-versions.outputs.versions }} | ||
latest: ${{ steps.set-latest.outputs.latest }} | ||
steps: | ||
- id: set-versions | ||
run: | | ||
echo "versions=${{ vars.SUPPORTED_PYTHON_VERSIONS }}" >> $GITHUB_OUTPUT | ||
- id: set-latest | ||
run: | | ||
sudo apt-get install -y jq | ||
latest=$(echo '${{ fromJSON(vars.SUPPORTED_PYTHON_VERSIONS) }}' | jq '.[-1]') | ||
echo "latest=$latest" >> $GITHUB_OUTPUT | ||
run-tests: | ||
needs: setup-matrix | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python_version: ${{ fromJSON(needs.setup-matrix.outputs.versions) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
cache: 'pip' | ||
|
||
- name: Load cached Poetry installation | ||
id: cached-poetry | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.local # the path depends on the OS | ||
key: poetry-${{ matrix.python_version }} # increment to reset cache | ||
|
||
- name: Setup Poetry | ||
uses: snok/install-poetry@v1 | ||
if: steps.cached-poetry.outputs.cache-hit != 'true' | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
poetry install --with=tests | ||
- name: Run Unittests | ||
run: > | ||
poetry run pytest | ||
--junitxml=test-report.xml | ||
--cov=nuvla | ||
--cov-report=xml | ||
--cov-report term | ||
--cov-config=.coveragerc | ||
--cov-branch | ||
- name: Install jq (For Quality Gate) | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
- name: SonarCloud Scan | ||
if: matrix.python_version == needs.setup-matrix.outputs.latest | ||
uses: SonarSource/sonarcloud-github-action@v2.1.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | ||
with: | ||
args: > | ||
-Dsonar.python.version=${{ matrix.python_version }} | ||
- name: SonarQube Quality Gate check | ||
if: matrix.python_version == needs.setup-matrix.outputs.latest | ||
uses: sonarsource/sonarqube-quality-gate-action@v1.1.0 | ||
# Force to fail step after specific time | ||
timeout-minutes: 5 | ||
with: | ||
scanMetadataReportFile: .scannerwork/report-task.txt | ||
env: | ||
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v1 | ||
if: always() | ||
with: | ||
check_name: "| UnitTest for Py${{ matrix.python_version }} |" | ||
files: test-report.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ target | |
versions.sh | ||
code/test-report.xml | ||
|
||
.tox/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.