Skip to content

Test CI (weekly) (notebooks: applications) #18

Test CI (weekly) (notebooks: applications)

Test CI (weekly) (notebooks: applications) #18

name: "Test CI (weekly) (notebooks: applications)"
on:
schedule:
- cron: "00 08 * * 6" # Saturday, 08:00 UTC
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
nightly-test:
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python and classiq and nightly aws
uses: ./.github/actions/setup_classiq_on_nightly
with:
aws-role: ${{ secrets.AWS_ROLE }}
codeartifact-domain: ${{ secrets.CODEARTIFACT_DOMAIN }}
codeartifact-owner: ${{ secrets.CODEARTIFACT_OWNER }}
codeartifact-region: ${{ secrets.CODEARTIFACT_REGION }}
nightly-m2m-secret-arn: ${{ secrets.NIGHTLY_M2M_SECRET_ARN }}
pypi-nightly-name: ${{ secrets.PYPI_NIGHTLY_NAME }}
- name: Get notebooks to tests
id: list-files
run: |
shopt -s globstar
echo "files=$(echo applications/**/*.ipynb)" >> $GITHUB_OUTPUT
# Run Notebook Tests
- name: Run Notebooks
run: python -m pytest --durations=0 --junitxml=pytest-results/test-results-applications.xml tests/notebooks
env:
# to disable a warning in Jupyter notebooks
JUPYTER_PLATFORM_DIRS: "1"
# Passing which notebooks changed
SHOULD_TEST_ALL_FILES: "false"
LIST_OF_IPYNB_CHANGED: "${{ steps.list-files.outputs.files }}"
LIST_OF_IPYNB_TESTS_CHANGED: ""
# Passing environment information
CLASSIQ_IDE: "https://nightly.platform.classiq.io"
CLASSIQ_HOST: "https://nightly.platform.classiq.io"
- name: Print failing tests
if: failure()
run: |
if [ -z "$(find ./pytest-results -name "*.xml")" ]; then
# Don't do anything if we don't have any results
exit 0
fi
{
echo "# Failing tests"
echo "| Test | Message |"
echo "| ---- | ------- |"
yq -o json -I 0 -p xml '
.testsuites[].testcase[] | select(.failure // .error) |
select((.failure // .error)["+@message"] | test("^((AssertionError: Qmod file)|(AssertionError: Found uncommitted Qmod)).*")) |
{
"name": (.["+@classname"] + "::" + .["+@name"]),
"message": (.failure // .error)["+@message"]
}
' ./pytest-results/*.xml | \
jq -r -s '
sort_by(.name) | .[] |
"| " + .name + " | " + (.message | @html | split("\n") | .[0]) + " |"
'
}>>"$GITHUB_STEP_SUMMARY"
- name: Send JSON to slack workflow
id: slack
if: failure()
uses: slackapi/slack-github-action@v2.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN1 }}
payload: |
{
"channel": "ci-notebooks-alerts",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Notification - Classiq library tests failed on branch ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Some Classiq library demos failed.\n*Make sure to take a look*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "hmm"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|Failed action URL>"
}
}
]
}