-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: refactor workflows to use a common shared workflow * chore: adds test run to datadog when the api key is defined * chore: warn if DD_API_KEY is not defined. * chore: try the `--ddtrace-patch-all` flag * style: line endings
- Loading branch information
Showing
3 changed files
with
115 additions
and
119 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
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,104 @@ | ||
# Reusable workflow to run the python CI, which covers | ||
# Optional notificiation to notehub (requires secrets NOTEHUB_SESSION_TOKEN, NOTEHUB_DEVICE_ID and NOTEHUB_PRODUCT_UID) | ||
# Python installation and dependencies | ||
# Linting (flake8 and docstyle) | ||
# Testing and coverage with pytest | ||
# Optionally publish coverage to coveralls (requires secrets.GITHUB_TOKEN) | ||
# Reports test coverage to DataDog if secrets.DD_API_KEY is defined. | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
NOTEHUB_SESSION_TOKEN: | ||
NOTEHUB_PRODUCT_UID: | ||
NOTECARD_DEVICE_ID: | ||
inputs: | ||
coveralls: | ||
type: boolean | ||
required: false | ||
default: false | ||
notehub_notify: | ||
type: boolean | ||
required: false | ||
default: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
|
||
env: | ||
DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
|
||
steps: | ||
- name: Send building notification | ||
if: ${{ inputs.notehub_notify }} | ||
run: | | ||
curl --request POST \ | ||
--url 'https://api.notefile.net/?product=${{ secrets.NOTEHUB_PRODUCT_UID }}&device=${{ secrets.NOTECARD_DEVICE_ID }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'X-Session-Token: ${{ secrets.NOTEHUB_SESSION_TOKEN }}' \ | ||
--data '{"req":"note.add","file":"build_results.qi","body":{"result":"building"}}' | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -U flake8 pytest coveralls ddtrace | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
make flake8 | ||
- name: Lint Docs with Pydocstyle | ||
run: | | ||
make docstyle | ||
- name: Send running tests notification | ||
if: ${{ inputs.notehub_notify }} | ||
run: | | ||
curl --request POST \ | ||
--url 'https://api.notefile.net/?product=${{ secrets.NOTEHUB_PRODUCT_UID }}&device=${{ secrets.NOTECARD_DEVICE_ID }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'X-Session-Token: ${{ secrets.NOTEHUB_SESSION_TOKEN }}' \ | ||
--data '{"req":"note.add","file":"build_results.qi","body":{"result":"running_tests"}}' | ||
- name: Check DD API Key | ||
if: ${{ !env.DD_API_KEY }} | ||
run: | | ||
echo Test run will NOT be collected by DD | ||
- name: Test with pytest | ||
env: | ||
DD_CIVISIBILITY_AGENTLESS_ENABLED: ${{ !!env.DD_API_KEY }} | ||
DD_SERVICE: note-python | ||
DD_ENV: ci | ||
run: | | ||
coverage run -m pytest --ddtrace --ddtrace-patch-all | ||
- name: Publish to Coveralls | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ inputs.coveralls }} | ||
run: | | ||
coveralls --service=github | ||
- name: Check if the job has succeeded | ||
if: ${{ success() && inputs.notehub_notify }} | ||
run: | | ||
curl --request POST \ | ||
--url 'https://api.notefile.net/?product=${{ secrets.NOTEHUB_PRODUCT_UID }}&device=${{ secrets.NOTECARD_DEVICE_ID }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'X-Session-Token: ${{ secrets.NOTEHUB_SESSION_TOKEN }}' \ | ||
--data '{"req":"note.add","file":"build_results.qi","body":{"result":"success"}}' | ||
- name: Check if the job has failed | ||
if: ${{ failure() && inputs.notehub_notify }} | ||
run: | | ||
curl --request POST \ | ||
--url 'https://api.notefile.net/?product=${{ secrets.NOTEHUB_PRODUCT_UID }}&device=${{ secrets.NOTECARD_DEVICE_ID }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'X-Session-Token: ${{ secrets.NOTEHUB_SESSION_TOKEN }}' \ | ||
--data '{"req":"note.add","file":"build_results.qi","body":{"result":"tests_failed"}}' |
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