From 454be018208b280a3b72594f244fbb757b4cebd6 Mon Sep 17 00:00:00 2001 From: Jean Henry <126060567+ansjhenry@users.noreply.github.com> Date: Fri, 16 Feb 2024 18:44:57 +0100 Subject: [PATCH] ci: Update the content according to ansys/actions (#2) * Update the content according to ansys/actions --- .flake8 | 4 + .github/labeler.yml | 2 + .github/labels.yml | 31 ++++++++ .github/workflows/ci_cd.yml | 141 ++++++++++++++++++++++++++++++++-- .pre-commit-config.yaml | 33 ++++++++ README.rst | 33 ++++++++ VERSION | 1 + create-scade-venv/action.yml | 4 +- get-scade-dir/action.yml | 2 +- get-scade-python/action.yml | 5 +- scade-tests-pytest/action.yml | 10 +-- 11 files changed, 249 insertions(+), 17 deletions(-) create mode 100644 .flake8 create mode 100644 .github/labeler.yml create mode 100644 .github/labels.yml create mode 100644 .pre-commit-config.yaml create mode 100644 README.rst create mode 100644 VERSION diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..a358831 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 88 +ignore = E501 +extend-ignore = E203, W503 diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..e5b01e6 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,2 @@ +maintenance: +- any-glob-to-any-file: ['.github/**/*', '.pre-commit-config.yaml', 'VERSION'] diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..cbc13d2 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,31 @@ +- name: bug + description: Something isn't working + color: d42a34 + +- name: blocked + description: Cannot address this till other issues are solved first + color: e0b063 + +- name: dependencies + description: Related with project dependencies + color: ffc0cb + +- name: documentation + description: Improvements or additions to documentation + color: 0677ba + +- name: enhancement + description: New features or code improvements + color: ffD827 + +- name: good first issue + description: Easy to solve for newcomers + color: 62ca50 + +- name: maintenance + description: Package and maintenance related + color: f78c37 + +- name: release + description: Anything related to an incoming release + color: ffffff diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 77f9c66..27802eb 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1,12 +1,18 @@ -name: GitHub CI +name: CI on: + pull_request: + workflow_dispatch: push: + tags: + - "v*.*.*" branches: - main - workflow_dispatch: env: - MAIN_SCADE_VERSION: '23.1' + MAIN_SCADE_VERSION: '23.2' + MAIN_PYTHON_VERSION: '3.10' + DOCUMENTATION_CNAME: 'scade-actions.docs.pyansys.com' + test-library-name: 'ansys-scade-actions' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -14,9 +20,121 @@ concurrency: 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@main + 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@main + 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@main + with: + skip-install: true + python-version: ${{ env.MAIN_PYTHON_VERSION }} + use-python-cache: false + tests: name: "Tests" - runs-on: self-hosted + runs-on: [self-hosted, 'SCADE'] strategy: matrix: # scade-version: ['19.2', '19.4', '21.1', '21.2'] @@ -25,21 +143,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - uses: ./get-scade-dir + + - name: Get SCADE installation directory + uses: ./get-scade-dir id: get-scade-dir with: scade-version: ${{ matrix.scade-version }} - - uses: ./get-scade-python + + - name: Get Python version + uses: ./get-scade-python id: get-scade-python with: scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }} - - uses: ./create-scade-venv + + - 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: Tests + + - name: Execute tests uses: ./scade-tests-pytest with: python-dir: ${{ steps.create-scade-venv.outputs.scripts-dir }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9f1ec9b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + +- repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: + - --line-length=88 + +- repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: requirements-txt-fixer + - id: trailing-whitespace + - id: debug-statements + +# Validate our github workflow files +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.22.0 + hooks: + - id: check-github-workflows \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..0141cd9 --- /dev/null +++ b/README.rst @@ -0,0 +1,33 @@ +.. readme_common_begins +Ansys SCADE actions +=================== +|ansys| |CI-CD| |MIT| + +.. |ansys| image:: https://img.shields.io/badge/Ansys-ffc107.svg?labelColor=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC + :target: https://actions.docs.ansys.com/ + :alt: Ansys + +.. |CI-CD| image:: https://github.com/ansys/actions/actions/workflows/ci_cd.yml/badge.svg + :target: https://github.com/ansys/actions/actions/workflows/ci_cd.yml + :alt: CI-CD + +.. |MIT| image:: https://img.shields.io/badge/License-MIT-blue.svg + :target: https://opensource.org/licenses/MIT + :alt: MIT + +A repository containing a collection of `GitHub Actions +`_ to be +reused by projects in the Ansys SCADE ecosystem. + +.. readme_common_ends + +For more information on available actions and how to use them, see +`scade-actions.docs.pyansys.com `_ . + + +Purpose +======= + +The Ansys SCADE actions prepare a SCADE environment for executing tests. + +They are driven by a Ansys SCADE version, such as ``23.1`` or ``24.1``, instead of a Python version, such as ``3.7`` or ``3.10``. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..cda1e48 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.dev0 diff --git a/create-scade-venv/action.yml b/create-scade-venv/action.yml index e342cd7..9c2465c 100644 --- a/create-scade-venv/action.yml +++ b/create-scade-venv/action.yml @@ -17,7 +17,7 @@ outputs: scripts-dir: description: Directory containing python.exe value: ${{ steps.venv.outputs.scripts-dir }} - + author: 'ESEG' runs: using: composite @@ -39,10 +39,10 @@ runs: if not exist "%VENV%" ( echo Create virtual environment "%VENV%" "%INPUT_PYTHON_DIR%\python.exe" -m venv "%VENV%" - rem add the environment to the path ) else ( echo Skip existing virtual environment "%VENV%" ) + rem add the environment to the path set PATH=%VENV%\Scripts;%PATH% python --version echo scripts-dir=%VENV%\Scripts>> %GITHUB_OUTPUT% diff --git a/get-scade-dir/action.yml b/get-scade-dir/action.yml index 46bd678..5ad681a 100644 --- a/get-scade-dir/action.yml +++ b/get-scade-dir/action.yml @@ -9,7 +9,7 @@ outputs: scade-directory: description: 'Intallation directory of the requested version' value: ${{ steps.find-scade-dir.outputs.scade-dir }} - + author: 'ESEG' runs: using: composite diff --git a/get-scade-python/action.yml b/get-scade-python/action.yml index 54e6bb9..0dc5645 100644 --- a/get-scade-python/action.yml +++ b/get-scade-python/action.yml @@ -5,17 +5,20 @@ inputs: scade-dir: description: 'C:\Program Files\ANSYS Inc\v231\SCADE' required: true + outputs: python-name: description: Name of the directory containing python.exe value: ${{ steps.get.outputs.python-name }} + python-dir: description: Directory containing python.exe value: ${{ steps.get.outputs.python-dir }} + python-version: description: Version of python.exe, two digits value: ${{ steps.get.outputs.python-version }} - + author: 'ESEG' runs: using: composite diff --git a/scade-tests-pytest/action.yml b/scade-tests-pytest/action.yml index 33e36a2..d7949f6 100644 --- a/scade-tests-pytest/action.yml +++ b/scade-tests-pytest/action.yml @@ -1,5 +1,5 @@ # scade-tests-pytest -# action derived from pyansys/actions/tests-pytest +# action derived from ansys/actions/tests-pytest name: > Tests pytest action @@ -46,11 +46,11 @@ inputs: runs: using: "composite" steps: - + - name: "Install Git and clone project" uses: actions/checkout@v3 if: ${{ inputs.checkout == 'true' }} - + - name: Pass Inputs to Shell shell: cmd run: | @@ -71,7 +71,7 @@ runs: shell: cmd run: | %PYTHON_EXE% -m pip install -U pip - + - name: "Install Python library" shell: cmd run: | @@ -90,7 +90,7 @@ runs: # shell: cmd # if: env.EXISTS_TESTS_REQUIREMENTS == 'false' # run: python -m pip install .[tests] - + - name: "Executing test suite" shell: cmd run: |