Skip to content

update README according to template (ISD-2745) #689

update README according to template (ISD-2745)

update README according to template (ISD-2745) #689

Workflow file for this run

# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
name: Application (Unit + Integration) Tests
on:
pull_request:
branches-ignore:
- '**test-branch/**'
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install tox
run: python3 -m pip install tox
- name: Run tests (unit + integration)
id: run-tests
env:
AUTH_GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
AUTH_GITHUB_APP_ID : ${{ secrets.TEST_GITHUB_APP_ID }}
AUTH_GITHUB_APP_INSTALLATION_ID : ${{ secrets.TEST_GITHUB_APP_INSTALLATION_ID }}
AUTH_GITHUB_APP_PRIVATE_KEY : ${{ secrets.TEST_GITHUB_APP_PRIVATE_KEY }}
run: |
# Ensure that stdout appears as normal and redirect to file and exit depends on exit code of first command
STDOUT_LOG=$(mktemp --suffix=stdout.log)
echo STDOUT_LOG=$STDOUT_LOG >> $GITHUB_ENV
tox -e test,coverage-report --result-json=test-result.json | tee $STDOUT_LOG ; test ${PIPESTATUS[0]} -eq 0
- name: Export test report
if: always()
uses: actions/github-script@v7
with:
script: |
const no_color = (text) => {
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
}
const sha = '${{ github.event.pull_request.head.sha }}';
const fs = require('fs');
const result = JSON.parse(fs.readFileSync('./test-result.json')).testenvs;
let lint_result = result.test.test;
let lint_success = lint_result[0].retcode == 0;
let lint_output = lint_result[0].output;
let coverage_result = result["coverage-report"].test;
let coverage_output = coverage_result[0].output;
let reports = [];
if (!lint_success) {
reports.push(
`Integration tests failed for ${sha}\n
\`\`\`\n${no_color(lint_output).trim()}\n\`\`\``
);
}
reports.push(
`Test coverage for ${sha}\n
\`\`\`\n${no_color(coverage_output).trim()}\n\`\`\``
);
let json = JSON.stringify(reports);
fs.writeFileSync('report_int.json', json);
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always() && github.event_name == 'pull_request'
with:
name: report
path: report_int.json
- name: Report
if: always()
id: report
run: echo "outcome=${{ steps.run-tests.conclusion }}" >> $GITHUB_OUTPUT