-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
96 upgrade workflow due to deprecation (#97)
* [QMI-096] Updated all v3 workflow actions to be v4. * [QMI-096] Created a reusable-ci-workflows.yml that has workflows that can be reused between the push, pull request and scheduled full test CI pipelines. Also renamed the files to be more descriptive. * [QMI-096] It complained about the `secrets` part. Trying to change that. * [QMI-096] I don't like secrets. * [QMI-096] Moving all `env` variables also to reusable-ci-workflows.yml * [QMI-096] Updating also JS node version for `setup-python@v4`. * [QMI-096] Updating also the CHANGELOG.md. And setup-python to v5 instead of forcing node-version. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Checking out main code in pull request before running reusable code. * [QMI-096] Updating the latest working solutions also to the `scheduled-full-ci.yml`. * [QMI-096] Still an issue with the artifacts namings. * [QMI-096] Still an issue with the artifacts namings. * [QMI-096] Move BADGES_DIR directly to pull request CI file. --------- Co-authored-by: Henri Ervasti <[email protected]> Co-authored-by: heevasti <[email protected]>
- Loading branch information
1 parent
8863069
commit 2fc7270
Showing
9 changed files
with
193 additions
and
281 deletions.
There are no files selected for viewing
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,51 @@ | ||
name: QMI Python CI runner on pull request | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
paths-ignore: | ||
- README.md | ||
- CHANGELOG.md | ||
- .gitignore | ||
- ACKNOWLEDGEMENTS.md | ||
- LICENSE.md | ||
- CONTRIBUTING.md | ||
- TESTING.md | ||
|
||
env: | ||
BADGES_DIR: ".github/badges" | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
max-parallel: 3 | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
|
||
uses: ./.github/workflows/reusable-ci-workflows.yml | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
ref: ${{ github.head_ref }} | ||
|
||
create-badges: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Generate and push badges | ||
if: ${{ matrix.python-version == '3.10' }} | ||
run: | | ||
pip install anybadge | ||
anybadge -o -l pylint -v $(tail -n 2 pylint.log | grep -o '[0-9]\{1,2\}\.[0-9]\{2\}' | head -n 1) -f $BADGES_DIR/pylint.svg 2=red 4=orange 8=yellow 10=green | ||
anybadge -o -l mypy -v $([ -n "$(tail -n 1 mypy.log | grep -e '^Succes')" ] && echo pass || echo fail) -f $BADGES_DIR/mypy.svg fail=red pass=green | ||
COVERAGE_PERC=$(grep "TOTAL" coverage.log | grep -Eo '[0-9.]+%' | sed 's/%//') | ||
anybadge -o -l coverage -v $COVERAGE_PERC -f $BADGES_DIR/coverage.svg 60=red 80=orange 100=green | ||
git config user.name "Badge Bot" | ||
git config user.email "<>" | ||
git add $BADGES_DIR/*.svg | ||
git commit -m "Update badges" || true | ||
git push || true |
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,18 @@ | ||
name: QMI Python CI runner on push | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- README.md | ||
- CHANGELOG.md | ||
- .gitignore | ||
- ACKNOWLEDGEMENTS.md | ||
- LICENSE.md | ||
- CONTRIBUTING.md | ||
- TESTING.md | ||
|
||
jobs: | ||
on_push: | ||
uses: ./.github/workflows/reusable-ci-workflows.yml | ||
with: | ||
python-version: "3.11" |
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 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,77 @@ | ||
name: Python CI Reusable Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
required: true | ||
type: string | ||
ref: | ||
required: false | ||
type: string | ||
|
||
env: | ||
PYLINT_MIN_SCORE: "9.00" | ||
COVERAGE_MIN_PERC: "90" | ||
COMPLEXITY_MAX_SCORE: "30" | ||
SOURCE_DIRS: "qmi/" | ||
BADGES_DIR: ".github/badges" | ||
|
||
jobs: | ||
ci-checks: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update -qy | ||
sudo apt-get install -y bc | ||
pip install --upgrade pip | ||
pip install -e '.[dev]' | ||
- name: Run pylint | ||
run: | | ||
pylint --score=yes --load-plugins=pylint.extensions.mccabe --max-complexity=$COMPLEXITY_MAX_SCORE $SOURCE_DIRS | tee pylint-${{ inputs.python-version }}.log | ||
PYLINT_SCORE=$(tail -n 2 pylint-${{ inputs.python-version }}.log | grep -o '[0-9]\{1,2\}\.[0-9]\{2\}' | head -n 1) | ||
echo "Pylint score: $PYLINT_SCORE" | ||
exit $(echo "$PYLINT_SCORE < $PYLINT_MIN_SCORE" | bc) | ||
- name: Upload pylint results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pylint-results-${{ inputs.python-version }} | ||
path: pylint-${{ inputs.python-version }}.log | ||
|
||
- name: Run mypy | ||
run: | | ||
mypy --namespace-packages $SOURCE_DIRS | tee mypy-${{ inputs.python-version }}.log | ||
if [ -n "$(tail -n 1 mypy-${{ inputs.python-version }}.log | grep -e '^Succes')" ]; then RESULT="pass"; else RESULT="fail"; fi | ||
echo "Mypy result: $RESULT" | ||
exit $([[ "$RESULT" == "pass" ]] && echo 0 || echo 1) | ||
- name: Upload mypy results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mypy-results-${{ inputs.python-version }} | ||
path: mypy-${{ inputs.python-version }}.log | ||
|
||
- name: Run coverage | ||
run: | | ||
coverage run --branch --source=$SOURCE_DIRS -m unittest discover --start-directory=tests --pattern="test_*.py" | ||
coverage report --show-missing --fail-under=$COVERAGE_MIN_PERC | tee coverage-${{ inputs.python-version }}.log | ||
COVERAGE_PERC=$(grep "TOTAL" coverage-${{ inputs.python-version }}.log | grep -Eo '[0-9.]+%' | sed 's/%//') | ||
echo "Coverage: $COVERAGE_PERC%" | ||
exit $(echo "$COVERAGE_PERC < $COVERAGE_MIN_PERC" | bc) | ||
- name: Upload coverage results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-results-${{ inputs.python-version }} | ||
path: coverage-${{ inputs.python-version }}.log |
Oops, something went wrong.