Skip to content

Commit

Permalink
CI: Reduce validation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Sep 25, 2024
1 parent 5a65956 commit ee166de
Showing 1 changed file with 5 additions and 111 deletions.
116 changes: 5 additions & 111 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# 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: Python package
name: Validations

on:
push:
branches: [ '*' ]
tags: [ '*' ]
pull_request:
branches: [ master, 'maint/*' ]
branches: [ master, main, 'maint/*' ]

env:
FORCE_COLOR: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,115 +17,10 @@ permissions:
contents: read

jobs:
job_metadata:
if: github.repository == 'nipreps/sdcflows'
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
version: ${{ steps.show_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}
- name: Detect version
id: show_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pip install -U build hatch hatchling pip twine docutils
VERSION=$( python -m hatch version | tail -n1 | xargs )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT
build:
if: github.repository == 'nipreps/sdcflows'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Build sdcflows
run: pipx run build
- name: Check distributions
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

test:
if: "!startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')"
needs: [build, job_metadata]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.12"]
install: [repo, sdist, wheel, editable]

env:
INSTALL_TYPE: ${{ matrix.install }}

steps:
- uses: actions/checkout@v4
if: matrix.install == 'repo' || matrix.install == 'editable'
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Fetch packages
if: matrix.install == 'sdist' || matrix.install == 'wheel'
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Select archive
run: |
if [ "$INSTALL_TYPE" = "sdist" ]; then
ARCHIVE=$( ls dist/*.tar.gz )
elif [ "$INSTALL_TYPE" = "wheel" ]; then
ARCHIVE=$( ls dist/*.whl )
elif [ "$INSTALL_TYPE" = "repo" ]; then
ARCHIVE="."
elif [ "$INSTALL_TYPE" = "editable" ]; then
ARCHIVE="-e ."
fi
echo "ARCHIVE=$ARCHIVE" | tee -a $GITHUB_ENV
- name: Install package
run: python -m pip install $ARCHIVE
- name: Check version
run: |
INSTALLED_VERSION=$(python -c 'import sdcflows; print(sdcflows.__version__, end="")')
echo "INSTALLED: \"${INSTALLED_VERSION}\""
test "${INSTALLED_VERSION}" = "${VERSION}"
env:
VERSION: ${{ needs.job_metadata.outputs.version }}

flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- run: pipx run flake8-pyproject sdcflows/

# codespell:
Expand Down

0 comments on commit ee166de

Please sign in to comment.