-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from lucas-labs/29-ci
ci: π push-pr ci config
- Loading branch information
Showing
17 changed files
with
552 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3-slim | ||
RUN pip install --upgrade pip | ||
RUN pip install requests tomli packaging | ||
|
||
COPY version_checker.py /version_checker.py | ||
|
||
ENTRYPOINT ["python3", "/version_checker.py"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# action.yaml | ||
name: "poetry project configuration" | ||
description: "get information about poetry project: version, name, description, etc." | ||
branding: | ||
icon: 'aperture' | ||
color: 'green' | ||
inputs: | ||
pyproject-path: | ||
description: "location of pyproject file" | ||
required: true | ||
default: "./pyproject.toml" | ||
outputs: | ||
is-local-higher: | ||
description: "True if local version is higher than public version" | ||
local-version: | ||
description: "Local version of the package" | ||
published-version: | ||
description: "Public version of the package" | ||
package-name: | ||
description: "Name of the package" | ||
package-description: | ||
description: "Description of the package" | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.pyproject-path }} | ||
- ${{ inputs.test-regex }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import sys | ||
|
||
import tomli | ||
from packaging import version | ||
|
||
# def get_public_version(project_name: str, is_test = False) -> Version: | ||
# response = requests.get( | ||
# f'https://{"test." if is_test else ""}pypi.org/pypi/{project_name}/json' | ||
# ) | ||
# response.raise_for_status() | ||
# return version.parse(json.loads(response.content)['info']['version']) | ||
|
||
|
||
if __name__ == '__main__': | ||
pyproject_toml_path = sys.argv[1] | ||
|
||
with open(pyproject_toml_path, 'rb') as f: | ||
project = tomli.load(f) | ||
|
||
print(project) | ||
|
||
# project_version = version.parse(project['tool']['poetry']['version']) | ||
name = project.get('tool', {}).get('poetry', {}).get('name', None) | ||
project_version = version.parse(project.get('tool', {}).get('poetry', {}).get('version', None)) | ||
description = project.get('tool', {}).get('poetry', {}).get('description', None) | ||
is_test = False | ||
# public_project_version = get_public_version(project['project']['name'], is_test) | ||
|
||
with open(os.environ['GITHUB_OUTPUT'], 'at') as f: | ||
# f.write( | ||
# f'local_version_is_higher={str(project_version > public_project_version).lower()}\n' | ||
# ) | ||
# f.write(f'public_version={str(public_project_version)}\n') | ||
f.write(f'local-version={str(project_version)}\n') | ||
f.write(f'package-name={name}\n') | ||
f.write(f'package-description={description}\n') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "π ci & publish" | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '**.md' | ||
- .editorconfig | ||
- .gitignore | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
if: | ||
github.event_name == 'pull_request' || | ||
startsWith(github.event.head_commit.message, 'release:') || | ||
startsWith(github.event.head_commit.message, 'release(') | ||
uses: ./.github/workflows/test.yml | ||
|
||
|
||
draft_release: | ||
if: | ||
github.event_name == 'push' && | ||
( | ||
startsWith(github.event.head_commit.message, 'release:') || | ||
startsWith(github.event.head_commit.message, 'release(') | ||
) | ||
needs: [tests] | ||
uses: ./.github/workflows/release.yml | ||
secrets: inherit | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: "ποΈ Β» setup environment" | ||
description: "setup all necessary tools for the workflow to run" | ||
inputs: | ||
python-version: | ||
description: "Version of python to install" | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: 'bash' | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: ποΈ Β» setup environment | ||
shell: bash | ||
run: echo "ποΈ Β» setup environment with python ${{inputs.python-version}}" | ||
|
||
- name: π Β» setup python@3 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{inputs.python-version}} | ||
cache: "pip" | ||
|
||
- name: π Β» install Poetry | ||
shell: bash | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python - -y | ||
- name: π Β» install nox | ||
shell: bash | ||
run: | | ||
pip install nox nox-poetry | ||
- name: π§ Β» install task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
version: 3.x | ||
|
||
- name: π Β» update PATH env var | ||
shell: bash | ||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
||
- name: π Β» log sysinfo | ||
shell: bash | ||
run: | | ||
uname -a | ||
python --version | ||
pip --version | ||
poetry --version | ||
task --version |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: "π Β» publish" | ||
on: | ||
release: | ||
types: [published] | ||
|
||
concurrency: | ||
group: publish-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: 'bash' | ||
|
||
jobs: | ||
publish-test-pypi: | ||
name: π Β» publish to test.pypi βοΈ | ||
if: ${{ github.event.act }} | ||
runs-on: ubuntu-latest | ||
environment: pypi-test | ||
steps: | ||
# checkout | ||
- name: π Β» checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: π Β» build & publish to test.pypi | ||
uses: JRubics/poetry-publish@v1.17 | ||
with: | ||
ignore_dev_requirements: "yes" | ||
pypi_token: ${{ secrets.PYPI_TOKEN }} | ||
repository_name: "testpypi" | ||
repository_url: "https://test.pypi.org/legacy/" | ||
|
||
publish: | ||
name: π Β» publish to pypi π | ||
if: ${{ !github.event.act }} | ||
runs-on: ubuntu-latest | ||
environment: pypi | ||
steps: | ||
# checkout | ||
- name: π Β» checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: π Β» build & publish to test.pypi | ||
uses: JRubics/poetry-publish@v1.17 | ||
with: | ||
ignore_dev_requirements: "yes" | ||
pypi_token: ${{ secrets.PYPI_TOKEN }} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: "π Β» draft release" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: release-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: 'bash' | ||
|
||
jobs: | ||
release: | ||
name: "π Β» draft release" | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-note: ${{ steps.changelog.outputs.changelog }} | ||
version: ${{ steps.version.outputs.local-version }} | ||
|
||
steps: | ||
- name: π Β» checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: β¬ οΈ Β» get previous git tag | ||
id: tag | ||
run: echo "last-tag=$(git describe --tags --abbrev=0 || git rev-list --max-parents=0 ${{github.ref}})" >> $GITHUB_OUTPUT | ||
|
||
- name: π·οΈ Β» get versions | ||
uses: ./.github/actions/check-version | ||
id: version | ||
with: | ||
pyproject-path: "./pyproject.toml" | ||
|
||
- name: π Β» generate changelog | ||
uses: lucaslabstech/action-release@v1.0.4 | ||
id: changelog | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
from: ${{ steps.tag.outputs.last-tag }} | ||
to: ${{ github.ref }} | ||
next-version: v${{ steps.version.outputs.local-version }} | ||
|
||
|
||
- name: ποΈ Β» delete outdated drafts | ||
uses: hugo19941994/delete-draft-releases@v1.0.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: π Β» create draft release | ||
uses: ncipollo/release-action@v1.11.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.github_token }} | ||
with: | ||
prerelease: false | ||
draft: true | ||
tag: v${{ steps.version.outputs.local-version }} | ||
name: v${{ steps.version.outputs.local-version }} | ||
body: ${{ steps.changelog.outputs.changelog }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: "π§ͺ Β» test" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: tests-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: 'bash' | ||
|
||
jobs: | ||
lint: | ||
name: "π§Ή Β» lint" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11"] | ||
|
||
steps: | ||
- name: π Β» checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: π Β» setup python, poetry and task | ||
uses: ./.github/workflows/composites/setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: π¦ Β» install ruff globally | ||
run: pip install ruff | ||
|
||
- name: π§Ή Β» lint | ||
run: task lint:check | ||
|
||
test: | ||
name: "π§ͺ Β» tests" | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- name: π Β» checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: π Β» setup python, poetry and task | ||
uses: ./.github/workflows/composites/setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: π§ͺ Β» run tests | ||
run: task test:${{ matrix.python-version }} | ||
|
||
# if python 3.11, upload coverage to codecov | ||
- name: βοΈ Β» upload coverage to codecov | ||
if: matrix.python-version == '3.11' | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml | ||
verbose: true |
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
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
Oops, something went wrong.