Skip to content

v1.2.0: improved CI and alignemtn with the eUDIW reference implementation #6

v1.2.0: improved CI and alignemtn with the eUDIW reference implementation

v1.2.0: improved CI and alignemtn with the eUDIW reference implementation #6

Workflow file for this run

# Code quality: flake8, isort, bandit
name: Code quality
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
skip-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.check.outputs.should_skip }}
steps:
- uses: actions/github-script@v7
id: check
with:
script: |
const branch = process.env.BRANCH || '';
const { data: { workflow_runs } } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
status: 'in_progress',
});
const otherRunning = workflow_runs.filter(
r => r.id != context.runId &&
r.name === context.workflow &&
(!branch || r.head_branch === branch)
);
core.setOutput('should_skip', otherRunning.length > 0 ? 'true' : 'false');
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
lint:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip flake8
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install -e .
- name: Run flake8
run: |
source env/bin/activate
flake8 pymdoccbor
isort:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: isort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip isort
pip install -e .
- name: Check import order with isort
run: |
source env/bin/activate
isort pymdoccbor --check-only --diff
bandit:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: Bandit security scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip bandit
pip install -e .
- name: Run Bandit security scan
run: |
source env/bin/activate
bandit -r -x pymdoccbor/tests pymdoccbor -f txt
radon:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: Radon complexity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip radon
pip install -e .
- name: Run Radon (maintainability index, no fail)
run: |
source env/bin/activate
radon cc pymdoccbor -a -n B || true
- name: Run Radon (raw metrics)
run: |
source env/bin/activate
radon raw pymdoccbor -s || true