Skip to content

Commit

Permalink
Issue 259 - Create GH Actions workflow to replace AppVeyor (#303)
Browse files Browse the repository at this point in the history
This PR addresses issue #259 to move the AppVeyor workflow to GH
Actions. Some differences:

- GHA workflow includes tests for Python 3.8 and 3.9 on Windows (these
can be excluded if required)
- GHA workflow tests the demo, check_style and docs as graphviz is
installed on the Windows runner (this makes Linux and Windows tests the
same)

**Important:** The Windows self-hosted runners differ from the GH
Actions runners in that they are not rebuilt after each workflow run.
Therefore, there is a chance the Windows runners could become corrupted.
A clean installation of the Windows runners can be made from AWS Images
if required.

---------

Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
  • Loading branch information
clyde-johnston and pavel-kirienko authored Aug 22, 2023
1 parent 01b9a9b commit f83ec3d
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 118 deletions.
114 changes: 0 additions & 114 deletions .appveyor.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: 'Test and Release PyCyphal'
on: push

# Ensures that only one workflow is running at a time
concurrency:
group: ${{ github.workflow_sha }}
cancel-in-progress: true

jobs:
pycyphal-test:
name: Test PyCyphal
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019-npcap ]
python: [ '3.7', '3.8', '3.9', '3.10' ]
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@v3

- name: Install Python3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Log Python version
run: python --version

- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get --ignore-missing update || true
sudo apt-get install -y linux-*-extra-$(uname -r) graphviz ncat
fi
git submodule update --init --recursive
python -m pip install --upgrade pip setuptools nox
shell: bash

- name: Collect Linux diagnostic data
if: ${{ runner.os == 'Linux' }}
run: ip link show

- name: Collect Windows diagnostic data
if: ${{ runner.os == 'Windows' }}
run: |
systeminfo
route print
ipconfig /all
- name: Run build and test
run: |
nox --non-interactive --error-on-missing-interpreters --session test pristine --python ${{ matrix.python }}
nox --non-interactive --session demo check_style docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: bash

- name: Save logs
uses: actions/upload-artifact@v3
with:
name: PyCyphal-${{ matrix.os }}-python-${{ matrix.python }}
path: .nox/*/*/*.log
retention-days: 7

pycyphal-release:
name: Release PyCyphal
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '#release') || contains(github.ref, '/master')
needs: pycyphal-test
steps:
- name: Check out
uses: actions/checkout@v3

- name: Create distribution wheel
run: |
git submodule update --init --recursive
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
- name: Get release version
run: |
cd pycyphal
echo "pycyphal_version=$(python -c 'from _version import __version__; print(__version__)')" >> $GITHUB_ENV
- name: Upload distribution
run: |
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN_PYCYPHAL }}

- name: Push version tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.pycyphal_version }}
tag_prefix: ''

4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ def test(session):
session.run("pylint", *map(str, src_dirs), env={"PYTHONPATH": str(compiled_dir)})

# Publish coverage statistics. This also has to be run from the test session to access the coverage files.
if sys.platform.startswith("linux") and is_latest_python(session) and session.env.get("COVERALLS_REPO_TOKEN"):
if sys.platform.startswith("linux") and is_latest_python(session) and session.env.get("GITHUB_TOKEN"):
session.install("coveralls")
session.run("coveralls")
else:
session.log("Coveralls skipped")

# Submit analysis to SonarCloud. This also has to be run from the test session to access the coverage files.
sonarcloud_token = session.env.get("SONARCLOUD_TOKEN")
sonarcloud_token = session.env.get("SONAR_TOKEN")
if sys.platform.startswith("linux") and is_latest_python(session) and sonarcloud_token:
session.run("coverage", "xml", "-i", "-o", str(ROOT_DIR / ".coverage.xml"))

Expand Down
2 changes: 1 addition & 1 deletion pycyphal/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.15.2"
__version__ = "1.15.3"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,4 @@ overgeneral-exceptions=BaseException
[doc8]
ignore-path = docs/api,./.nox,./pycyphal.egg-info
max-line-length = 120
ignore = D000
ignore = D000,D002,D004

0 comments on commit f83ec3d

Please sign in to comment.