Skip to content

Update CI.yml (#24) #38

Update CI.yml (#24)

Update CI.yml (#24) #38

Workflow file for this run

name: CI
on: [push]
jobs:
RunTests:
runs-on: ${{ matrix.os }}
# Don't run tests when merging PRs, they would have been run already and tests
# should have passed. The following checks hat the committer's username is web-flow;
# if it is, it's probably from github actions.
# NOTE: Directly editing code on GitHub on the main branch pybasses tests, and is
# discouraged. If editing code on GitHub, please submit a PR by creating a temporary branch.
if: |
github.ref != 'refs/heads/main' ||
!contains(github.event.head_commit.committer.username, 'web-flow')
continue-on-error: ${{ matrix.python-version == 3.6 || matrix.os == 'windows-latest' }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.12']
include:
- os: ubuntu-20.04
python-version: 3.6
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest
- name: Run Pytest
run: pytest -s tests/
CreateTag:
permissions:
contents: write
needs: RunTests
runs-on: ubuntu-latest
defaults:
run:
shell: bash
# Create tag only on master branch and tests pass or tests were skipped
# (i.e. skipped due to a PR merge; in that case tests should already have
# passed).
if: |
always() &&
github.ref == 'refs/heads/master' &&
(needs.RunTests.result == 'success' || needs.RunTests.result == 'skipped')
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install setuptools
run: |
python -m pip install --upgrade pip
pip install setuptools
- name: Get python package metadata
id: pkg_info
run: |
echo "version=v$(python setup.py --version)" >> "$GITHUB_OUTPUT"
- name: Get git info
id: git_info
run: |
git fetch --tags
echo "tag=$(git tag | sort -V | tail -n 1)" >> "$GITHUB_OUTPUT"
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Make tag if updated
if: ${{ (steps.pkg_info.outputs.version != steps.git_info.outputs.tag) }}
env:
pkg_version: ${{ steps.pkg_info.outputs.version }}
run: |
git tag "$pkg_version"
git push --tags