Skip to content

Add vulnerability checks #3

Add vulnerability checks

Add vulnerability checks #3

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions: {}
jobs:
paths-filter:
runs-on: ubuntu-latest
outputs:
hasChanges: ${{ steps.filter.outputs.source == 'true' || steps.filter.outputs.test == 'true' || steps.filter.outputs.workflow == 'true' || steps.filter.outputs.dependancies == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
source:
- "src/**"
test:
- "tests/**"
workflow:
- ".github/workflows/**"
dependancies:
- "poetry.lock"
- "pyproject.toml"
- name: source has changes
run: echo "source has changes"
if: steps.filter.outputs.source == 'true'
- name: test has changes
run: echo "test has changes"
if: steps.filter.outputs.test == 'true'
- name: workflow has changes
run: echo "workflow has changes"
if: steps.filter.outputs.workflow == 'true'
- name: dependancies have changes
run: echo "dependancies have changes"
if: steps.filter.outputs.dependancies == 'true'
build_and_test:
needs: paths-filter
if: needs.paths-filter.outputs.hasChanges == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install packages and dependencies
run: |
pip install poetry
poetry install --without dev
poetry run python -c "from pydtl_relativepath import rel2abs"
- name: Test with pytest
run: |
poetry run pytest
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .pytest_results/coverage_report/coverage.xml
flags: tests
test-check:
if: always()
runs-on: ubuntu-latest
needs: [build_and_test]
steps:
- name: Get Date
shell: bash
run: |
echo "date=$(date +'%m/%d/%Y %H:%M:%S')" >> "$GITHUB_ENV"
- name: Run Type is ${{ github.event_name }}
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'}}
shell: bash
run: |
echo "run_type=${{ github.event_name }}" >> "$GITHUB_ENV"
- name: Fail workflow if build failed
id: check_build_failed
if: contains(join(needs.*.result, ','), 'failure')
uses: actions/github-script@v6
with:
script: core.setFailed('Build Failed!')
- name: Fail workflow if build cancelled
id: check_build_cancelled
if: contains(join(needs.*.result, ','), 'cancelled')
uses: actions/github-script@v6
with:
script: core.setFailed('Build Cancelled!')