test: Setup tests (#4) #14
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
name: CI | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*.*.*" | |
branches: | |
- main | |
env: | |
MAIN_SCADE_VERSION: '23.2' | |
MAIN_PYTHON_VERSION: '3.10' | |
DOCUMENTATION_CNAME: 'actions.scade.docs.pyansys.com' | |
test-library-name: 'ansys-scade-actions' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
labeler: | |
name: "Label syncer" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: micnncim/action-label-syncer@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Label based on changed files | |
uses: actions/labeler@v5 | |
with: | |
repo-token: "${{ secrets.GITHUB_TOKEN }}" | |
- uses: actions-ecosystem/action-add-labels@v1 | |
if: | | |
startsWith(github.event.pull_request.head.ref, 'doc') || | |
startsWith(github.event.pull_request.head.ref, 'docs') | |
with: | |
labels: documentation | |
- uses: actions-ecosystem/action-add-labels@v1 | |
if: | | |
startsWith(github.event.pull_request.head.ref, 'maint') || | |
startsWith(github.event.pull_request.head.ref, 'no-ci') || | |
startsWith(github.event.pull_request.head.ref, 'ci') | |
with: | |
labels: maintenance | |
- uses: actions-ecosystem/action-add-labels@v1 | |
if: startsWith(github.event.pull_request.head.ref, 'feat') | |
with: | |
labels: | | |
enhancement | |
- uses: actions-ecosystem/action-add-labels@v1 | |
if: | | |
startsWith(github.event.pull_request.head.ref, 'fix') || | |
startsWith(github.event.pull_request.head.ref, 'patch') | |
with: | |
labels: bug | |
- name: Suggest to add labels | |
uses: peter-evans/create-or-update-comment@v4 | |
if: toJSON(github.event.pull_request.labels.*.name) == '{}' | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Please add one of the following labels to add this contribution to the Release Notes :point_down: | |
- [bug](https://github.com/ansys/actions/pulls?q=label%3Abug+) | |
- [documentation](https://github.com/ansys/actions/pulls?q=label%3Adocumentation+) | |
- [enhancement](https://github.com/ansys/actions/pulls?q=label%3Aenhancement+) | |
- [good first issue](https://github.com/ansys/actions/pulls?q=label%3Agood+first+issue) | |
- [maintenance](https://github.com/ansys/actions/pulls?q=label%3Amaintenance+) | |
- [release](https://github.com/ansys/actions/pulls?q=label%3Arelease+) | |
commit-and-branch-style: | |
name: "Commit and branch style" | |
runs-on: ubuntu-latest | |
needs: labeler | |
steps: | |
- uses: ansys/actions/commit-style@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: ansys/actions/branch-name-style@main | |
code-style: | |
name: "Code style" | |
runs-on: ubuntu-latest | |
needs: commit-and-branch-style | |
steps: | |
- name: "Run code style checks" | |
uses: ansys/actions/code-style@v5 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
use-python-cache: false | |
- name: "Verify private actions are not pointing to the 'main' branch" | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
run: | | |
if $(grep -q --exclude-dir={.git,.github,doc} "ansys\/actions\/.*\@main" -r .); then | |
echo -e "\033[1;91m[ERROR]: Found private actions pointing to the 'main' branch.\033[0m" | |
grep -q --exclude-dir={.git,.github,doc} "ansys\/actions\/.*\@main" -r . | |
fi | |
doc-style: | |
name: "Doc style" | |
runs-on: ubuntu-latest | |
needs: commit-and-branch-style | |
steps: | |
- name: "Run documentation style checks" | |
uses: ansys/actions/doc-style@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-build: | |
name: "Doc build" | |
runs-on: ubuntu-latest | |
needs: doc-style | |
steps: | |
- name: "Build documentation" | |
uses: ansys/actions/doc-build@v5 | |
with: | |
skip-install: true | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
use-python-cache: false | |
tests: | |
name: "Tests" | |
runs-on: [self-hosted, 'SCADE'] | |
strategy: | |
matrix: | |
# scade-version: ['23.1', '23.2'] | |
scade-version: ['23.1'] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get SCADE installation directory | |
uses: ./get-scade-dir | |
id: get-scade-dir | |
with: | |
scade-version: ${{ matrix.scade-version }} | |
- name: Get Python version | |
uses: ./get-scade-python | |
id: get-scade-python | |
with: | |
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }} | |
- name: Create a Python virtual environment | |
uses: ./create-scade-venv | |
id: create-scade-venv | |
with: | |
python-dir: ${{ steps.get-scade-python.outputs.python-dir }} | |
target-dir: '.venvs' | |
target-name: ${{ steps.get-scade-python.outputs.python-name }} | |
- name: Execute tests | |
uses: ./scade-tests-pytest | |
with: | |
python-dir: ${{ steps.create-scade-venv.outputs.scripts-dir }} | |
library-dir: "tests/python" | |
pytest-postargs: "tests/python/tests -vv" | |
checkout: false | |
doc-deploy-dev: | |
name: "Deploy developers documentation" | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && !contains(github.ref, 'refs/tags') | |
needs: [doc-build, tests] | |
steps: | |
- uses: ansys/actions/doc-deploy-dev@v5 | |
with: | |
cname: ${{ env.DOCUMENTATION_CNAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} |