Skip to content

Commit

Permalink
ci: Update the content according to ansys/actions (#2)
Browse files Browse the repository at this point in the history
* Update the content according to ansys/actions
  • Loading branch information
ansjhenry authored Feb 16, 2024
1 parent 550df88 commit 454be01
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
ignore = E501
extend-ignore = E203, W503
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
maintenance:
- any-glob-to-any-file: ['.github/**/*', '.pre-commit-config.yaml', 'VERSION']
31 changes: 31 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -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
141 changes: 133 additions & 8 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,140 @@
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 }}
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@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']
Expand All @@ -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 }}
Expand Down
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
<https://docs.github.com/en/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 <https://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``.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.dev0
4 changes: 2 additions & 2 deletions create-scade-venv/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ outputs:
scripts-dir:
description: Directory containing python.exe
value: ${{ steps.venv.outputs.scripts-dir }}

author: 'ESEG'
runs:
using: composite
Expand All @@ -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%
2 changes: 1 addition & 1 deletion get-scade-dir/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion get-scade-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scade-tests-pytest/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -71,7 +71,7 @@ runs:
shell: cmd
run: |
%PYTHON_EXE% -m pip install -U pip
- name: "Install Python library"
shell: cmd
run: |
Expand All @@ -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: |
Expand Down

0 comments on commit 454be01

Please sign in to comment.