Skip to content

Commit

Permalink
Merge branch 'develop' into ds/chore/fast-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkschumacher authored Nov 15, 2024
2 parents d7d2aff + 7700ca4 commit 85e9f3f
Show file tree
Hide file tree
Showing 140 changed files with 7,631 additions and 334 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: go test
run: go test ./...
- name: go test (exclude golden file tests from Python package)
run: go test $(go list ./... | grep -v github.com/nextmv-io/nextroute/src)
8 changes: 6 additions & 2 deletions .github/workflows/header.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on: [push]
jobs:
check-header:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ["go", "python"]
steps:
- name: git clone
uses: actions/checkout@v4
Expand All @@ -12,6 +16,6 @@ jobs:
with:
python-version: "3.12"

- name: check header in .go files
- name: check header in ${{ matrix.language }} files
run: |
python .nextmv/check_header.py
HEADER_CHECK_LANGUAGE=${{ matrix.language }} python .nextmv/check_header.py
25 changes: 25 additions & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: python lint
on: [push]
jobs:
python-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: lint with ruff
run: ruff check --output-format=github -v .
49 changes: 49 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: python test
on: [push]

env:
GO_VERSION: 1.23

jobs:
python-test:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
platform: [ubuntu-latest, windows-latest, macos-latest, macos-13]
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Python unit tests
run: python -m unittest
working-directory: src

# There appears to be a bug around
# `nextmv-io/[email protected]/golden/file.go:75` specifically in Windows. When
# attempting to remove a temp file, the following error is encountered:
# `panic: remove C:\Users\RUNNER~1\AppData\Local\Temp\output1368198263:
# The process cannot access the file because it is being used by another
# process.` We need to figure out why it only happens in Windows. Until
# then, we will not run the golden file tests in Windows.
# Source:https://github.com/nextmv-io/nextroute/actions/runs/11414952328/job/31764458969?pr=65
- name: set up Go
if: ${{ matrix.platform != 'windows-latest' }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: golden file tests from Python package
if: ${{ matrix.platform != 'windows-latest' }}
run: go test $(go list ./... | grep github.com/nextmv-io/nextroute/src)
184 changes: 182 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: release
run-name: Release ${{ inputs.VERSION }} (pre-release - ${{ inputs.IS_PRE_RELEASE }}) by @${{ github.actor }} from ${{ github.ref_name }}

on:
workflow_dispatch:
Expand All @@ -12,8 +13,12 @@ on:
default: true
type: boolean

env:
GO_VERSION: 1.23
PYTHON_VERSION: 3.12

jobs:
release:
bump-version:
runs-on: ubuntu-latest
env:
VERSION: ${{ inputs.VERSION }}
Expand All @@ -36,6 +41,24 @@ jobs:
exit 1
fi
fi
- name: ensure version is not already released
run: |
if git ls-remote --tags origin | grep -q "refs/tags/$VERSION"; then
echo "Version $VERSION already exists"
exit 1
fi
- name: set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: configure git with the bot credentials
run: |
mkdir -p ~/.ssh
Expand All @@ -58,8 +81,29 @@ jobs:
git rev-parse --short HEAD
- name: push release tag
- name: install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
working-directory: ./nextroute

- name: bump version in version file for Go
run: |
echo $VERSION > VERSION
working-directory: ./nextroute

- name: upgrade version with hatch for Python
run: hatch version ${{ env.VERSION }}
working-directory: ./nextroute

- name: commit version bump
run: |
git add VERSION
git add src/nextroute/__about__.py
git commit -S -m "Bump version to $VERSION"
git push
git tag $VERSION
git push origin $VERSION
working-directory: ./nextroute
Expand All @@ -76,3 +120,139 @@ jobs:
--generate-notes \
--title $VERSION $PRERELEASE_FLAG
working-directory: ./nextroute

build-sdist:
name: wheels-sdist
needs: bump-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Build sdist
run: pipx run build --sdist

- name: Check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v4
with:
name: wheels-artifacts-sdist
path: dist/*.tar.gz

build-wheels:
name: wheels-${{ matrix.platform }}
needs: bump-version
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- image: ubuntu-latest
platform: linux
- image: macos-13
platform: macos-amd64
- image: macos-14
platform: macos-arm64
- image: windows-latest
platform: windows

steps:
- name: git clone ${{ github.ref_name }}
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up QEMU
if: matrix.platform == 'linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
if: matrix.platform != 'macos-arm64'
uses: pypa/[email protected]
env:
MACOSX_DEPLOYMENT_TARGET: 13.0

- name: Build wheels
if: matrix.platform == 'macos-arm64'
uses: pypa/[email protected]
env:
# TODO: default wheel repair does not recognize the arm64 wheel.
# This seems like a bug in delocate-wheel, which is the tool used by cibuildwheel,
# since the binary works fine when installed. However, we skip a more thorough
# investigation for now and just disable the repair step.
CIBW_REPAIR_WHEEL_COMMAND: ""
MACOSX_DEPLOYMENT_TARGET: 14.0

- name: Verify clean directory
run: git diff --exit-code
shell: bash

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-artifacts-${{ matrix.platform }}
path: wheelhouse/*.whl

release:
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
strategy:
matrix:
include:
- target-env: pypi
target-url: https://pypi.org/p/nextroute
- target-env: testpypi
target-url: https://test.pypi.org/p/nextroute
environment:
name: ${{ matrix.target-env }}
url: ${{ matrix.target-url }}
permissions:
contents: read
id-token: write # This is required for trusted publishing to PyPI
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist

- name: Print directory tree for reference
uses: jaywcjlove/github-action-folder-tree@main
with:
path: ./

- name: Publish package distributions to PyPI
if: ${{ matrix.target-env == 'pypi' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist

- name: Publish package distributions to TestPyPI
if: ${{ matrix.target-env == 'testpypi' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: ./dist

notify:
runs-on: ubuntu-latest
needs: release
if: ${{ needs.release.result == 'success' && inputs.IS_PRE_RELEASE == false }}
steps:
- name: notify slack
run: |
export DATA="{\"text\":\"Release notification - nextroute ${{ inputs.VERSION }} (see <https://github.com/nextmv-io/nextroute/releases/${{ inputs.VERSION }}|release notes> / <https://pypi.org/project/nextroute|PyPI>)\"}"
curl -X POST -H 'Content-type: application/json' --data "$DATA" ${{ secrets.SLACK_URL_MISSION_CONTROL }}
Loading

0 comments on commit 85e9f3f

Please sign in to comment.