Merge pull request #20 from lanl/alui/ci-fix #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
RunTests: | |
runs-on: ${{ matrix.os }} | |
if: ${{ !contains(github.event.head_commit.message, 'Merge pull request') }} | |
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: | | |
github.ref == 'refs/heads/master' && | |
(needs.RunTest.result == 'success' || needs.RunTest.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 | |