Skip to content

Commit

Permalink
Merge pull request #4 from mnbf9rca/chore/build_publish_workflow
Browse files Browse the repository at this point in the history
create single workflow for build, test, publish
  • Loading branch information
mnbf9rca authored Jul 9, 2024
2 parents 87c3ec9 + 3bb5944 commit 29b9419
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}

}

// Features to add to the dev container. More info: https://containers.dev/features.
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Publish the completed package to Pypi

on:
push:
branches:
- main

# permissions: # Global permissions configuration starts here
# contents: read # 'read' access to repository contents
# pull-requests: read # 'write' access to pull requests

jobs:
codeql:
permissions:
actions: read
contents: read
security-events: write
uses: ./.github/workflows/codeql.yml

test:
uses: ./.github/workflows/test-workflow.yml

dependency-review:
uses: ./.github/workflows/dependency-review.yml

publish:
needs: [test, dependency-review, codeql]
runs-on: ubuntu-latest
environment:
name: 'published'
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
pull-requests: write # 'write' access to pull requests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1
with:
version: 1.8.3 # pin the version as they keep changing their APIs
virtualenvs-create: false
virtualenvs-in-project: false
- name: Install dependencies
run: |
python -m venv venv
. venv/bin/activate
poetry install --with dev --no-interaction --sync
python -c "import os; print(os.environ['VIRTUAL_ENV'])"
- name: Bump version
run: |
poetry version minor
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add pyproject.toml
git commit -m "bump version from workflow"
git push origin HEAD:${{ github.head_ref }}
- name: Build
run: poetry build
- name: Use Pypi test
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi ${{ secrets.PYPI_TOKEN }}
- name: Publish
run: poetry publish -r test-pypi


11 changes: 5 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: CodeQL

on:
workflow_call:
push:
branches: ["*", "*/*"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["*", "*/*"]
branches-ignore:
- main
schedule:
- cron: "43 4 * * 3"

Expand Down Expand Up @@ -72,4 +71,4 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3
with:
category: "/language:${{matrix.language}}"
category: "/language:${{matrix.language}}"
3 changes: 2 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]
on:
workflow_call:

permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
name: Python package
name: test package

on:
workflow_call:
push:
branches-ignore:
- main
pull_request:
branches:
- main
branches-ignore:
- main


permissions: # Global permissions configuration starts here
contents: read # 'read' access to repository contents
pull-requests: read # 'write' access to pull requests

jobs:
test:
strategy:
matrix:
python-version: ["3.12"]
runs-on: ubuntu-latest
container: ubuntu:latest@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OS dependencies for snok/install-poetry
run: |
DEBIAN_FRONTEND=noninteractive apt update
DEBIAN_FRONTEND=noninteractive apt install curl sqlite3 -y
- uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1
with:
version: 1.8.3 # pin the version as they keep changing their APIs
Expand All @@ -50,4 +48,4 @@ jobs:
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[tool.poetry]
name = "pydantic-tfl-api"
version = "0.1.0"
version = "0.2.0"
description = "A Pydantic-based wrapper for the TfL Unified API https://api.tfl.gov.uk/. Not associated with or endorsed by TfL."
authors = ["Rob Aleck <[email protected]>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/mnbf9rca/pydantic_tfl_api"
repository = "https://github.com/mnbf9rca/pydantic_tfl_api"

[tool.poetry.dependencies]
python = "^3.12"
pydantic = "^2.8.2"
requests = "^2.32.3"
pydantic = ">=2.8.2"
requests = ">=2.32.3"

[tool.poetry.group.dev.dependencies]
black = "^24.4.2"
Expand Down

0 comments on commit 29b9419

Please sign in to comment.