Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic CI Workflows #8

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish release

on:
release:
branches:
- master
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine build
- name: Make sure version in atom_tools.__init__.py has been updated
run: |
version=$(python3 -c 'from atom_tools.__init__ import __version__; print(f"refs/tags/v{__version__}")')
if $version != ${{ github.ref }}; then
echo "Version in atom_tools.__init__.py has not been updated. $version != ${{ github.ref }}"
exit 1
fi
- name: Create Release
id: create_release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
python3 -m build
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Python matrix CI

on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
- 'dockertests.yml'
- 'dockertests.yml'
- 'python-publish.yml'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools
python3 -m pip install .[dev]
- name: Tox
run: |
python3 -m tox
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dev = [
"isort",
"pre-commit",
"pylint",
"pytest",
"tox",
]

Expand Down
4 changes: 2 additions & 2 deletions test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_openapi_class():
openapi = OpenAPI('openapi3.1.0', 'java',
'data/java-piggymetrics-usages.json')
'test/data/java-piggymetrics-usages.json')
assert openapi.openapi_version == '3.1.0'
assert openapi.origin_type == 'java'
assert openapi.endpoints_to_openapi() == {
Expand All @@ -18,7 +18,7 @@ def test_openapi_class():
'/uaa/users', '/{accountName}',
'/{name}']

openapi = OpenAPI('openapi3.0.1', 'java', 'data/java-sec-code-usages.json')
openapi = OpenAPI('openapi3.0.1', 'java', 'test/data/java-sec-code-usages.json')
assert openapi.openapi_version == '3.0.1'
assert openapi.origin_type == 'java'
assert openapi.endpoints_to_openapi() == {
Expand Down
4 changes: 2 additions & 2 deletions test/test_slices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


def test_usages_class():
usages = UsageSlice('data/java-piggymetrics-usages.json', 'java')
usages = UsageSlice('test/data/java-piggymetrics-usages.json', 'java')
assert usages.language == 'java'
result = usages.generate_endpoints()
result.sort()
assert result == ['/', '/accounts/{accountName}', '/current', '/latest',
'/statistics/{accountName}', '/uaa/users',
'/{accountName}', '/{name}']

usages = UsageSlice('data/java-sec-code-usages.json', 'java')
usages = UsageSlice('test/data/java-sec-code-usages.json', 'java')
assert usages.language == 'java'
result = usages.generate_endpoints()
result.sort()
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tox]
minversion = 4.0
envlist = py310, py311, py312

[testenv]
deps = pytest
commands = pytest test