Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement #4

Merged
merged 15 commits into from
Nov 19, 2024
Prev Previous commit
Next Next commit
Reconfigure CI
  • Loading branch information
LecrisUT committed Nov 19, 2024
commit f542ed7db62df5577aa3262edfd1a756289b1220
56 changes: 29 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
name: CI
run-name: >
CI (${{ github.event_name }})
${{ github.event_name == 'pull_request' && format('PR#{0}', github.event.number) || '' }}

on:
workflow_dispatch:
inputs:
upload-wheel:
type: boolean
required: false
default: false
description: Upload wheel as an artifact
pytest-flags:
type: string
required: false
description: Additional flags to add to pytest
pull_request:
push:
branches: [ main ]
schedule:
- cron: 0 0 * * 3

permissions:
contents: read
@@ -31,32 +26,39 @@ jobs:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml
with:
pytest-flags: ${{ inputs.pytest-flags }}
mask-experimental: ${{ github.event_name == 'push' }}

code-analysis:
uses: ./.github/workflows/step_code-analysis.yaml
coverage:
name: 👀 coverage
needs: [ tests ]
uses: ./.github/workflows/step_coverage.yaml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: github.event_name != 'schedule'

docs:
name: 📘 docs
needs: [ pre-commit ]
uses: ./.github/workflows/step_docs.yaml

build:
needs: [ pre-commit ]
uses: ./.github/workflows/step_build.yaml

static-analysis:
needs: [ pre-commit ]
uses: ./.github/workflows/step_static-analysis.yaml
secrets:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
permissions:
security-events: write
contents: write
checks: write
pull-requests: write

build-wheel:
uses: ./.github/workflows/step_build-wheel.yaml
needs: [ tests ]
with:
upload: ${{ inputs.upload-wheel || false }}
if: github.event_name != 'schedule'

pass:
name: Pass
needs: [ pre-commit, tests, build-wheel, code-analysis ]
name: Pass
needs: [ pre-commit, tests, coverage, docs, build, static-analysis ]
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
allowed-skips: code-analysis
allowed-skips: coverage, static-analysis
jobs: ${{ toJSON(needs) }}
if: always()
19 changes: 9 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
name: Prepare release
name: 🚀 Release
run-name: >
🚀 Release
${{ github.ref_name }}

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/step_test.yaml
build-wheel:
needs: [ tests ]
uses: ./.github/workflows/step_build-wheel.yaml
uses: ./.github/workflows/step_build.yaml
upload_pypi:
name: Upload to PyPI repository
needs: [ tests, build-wheel ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/spglib/
url: https://pypi.org/project/fmf-jinja/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
name: Packages
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
@@ -37,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v2
with:
name: FMF-Jinja ${{ github.ref_name }}
draft: true
23 changes: 0 additions & 23 deletions .github/workflows/step_build-wheel.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/step_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
workflow_call:

permissions:
contents: read

jobs:
build:
name: 🐍 sdist/wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
32 changes: 0 additions & 32 deletions .github/workflows/step_code-analysis.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/step_coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 👀 coverage

on:
workflow_call:
secrets:
CODECOV_TOKEN:
description: Codecov token of the main repository
required: false

permissions:
contents: read

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install package
run: pip install -e .[test-cov]
- name: Test package
run: pytest --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/step_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_call:

permissions:
contents: read

jobs:
sphinx:
name: Sphinx (${{ matrix.builder }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
builder: [ linkcheck, html ]
include:
# Run default html builder with warnings as error
- builder: html
args: -W
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install the project and docs dependencies
run: pip install -e .[docs]
- name: Run sphinx builder ${{ matrix.builder }}
run: sphinx-build -b ${{ matrix.builder }} ${{ matrix.args }} ./docs ./docs/_build
6 changes: 2 additions & 4 deletions .github/workflows/step_pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: pre-commit

on:
workflow_call:

@@ -12,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected].0
- uses: pre-commit/[email protected].1
19 changes: 19 additions & 0 deletions .github/workflows/step_static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: static-analysis

on:
workflow_call:
secrets:
QODANA_TOKEN:
required: true

jobs:
qodana:
name: Qodana
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
42 changes: 28 additions & 14 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
on:
workflow_call:
inputs:
pytest-flags:
type: string
required: false
description: Additional flags to add to pytest
mask-experimental:
type: boolean
default: true
description: Always report experimental test as successful

permissions:
contents: read

jobs:
checks:
name:
Check 🐍 ${{ matrix.python-version }}
name: >
🐍 ${{ matrix.python-version }}
🌳 ${{ matrix.tmt-version || 'latest' }}
⛩️ ${{ matrix.jinja-version || 'latest' }}
${{ matrix.experimental && '[🧪 Experimental]' || '' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: [ "3.9", "3.x" ]
tmt-version: [ "" ]
jinja-version: [ "" ]
include:
- python-version: "3.x"
jinja-version: "main"
tmt-version: "main"
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install -e .[test-cov]
run: pip install -e .[test]
- name: Install fmf ${{ matrix.tmt-version }}
run: pip install fmf@git+https://github.com/teemtee/fmf@${{ matrix.tmt-version }}
if: matrix.tmt-version
- name: Install jinja ${{ matrix.jinja-version }}
run: pip install jinja2@git+https://github.com/pallets/jinja/@${{ matrix.tmt-version }}
if: matrix.jinja-version
- name: Test package
run: pytest --cov --cov-report=xml ${{ inputs.pytest-flags }}
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
name: python-${{ matrix.python-version }}
run: pytest
continue-on-error: ${{ matrix.experimental && inputs.mask-experimental}}
30 changes: 2 additions & 28 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
bootstrap: |
# https://youtrack.jetbrains.com/issue/QD-2706
rm -rf .idea
pip install -e .[test]

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-python:latest
pip install -e .
linter: jetbrains/qodana-python-community:latest