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

Add release workflow #2004

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip==22.3.1
poetry==1.2.2
virtualenv==20.16.7
22 changes: 16 additions & 6 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.9"]

steps:
- uses: actions/checkout@v2
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: pip cache
uses: actions/cache@v2
Expand All @@ -25,11 +28,18 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade poetry
poetry install
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version

- name: Install dependencies
run: poetry install

- name: Test integration
run: ./scripts/test_integration.sh
27 changes: 19 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.9"]

steps:
- uses: actions/checkout@v2
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: pip cache
uses: actions/cache@v2
Expand All @@ -25,11 +28,19 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade poetry
poetry install
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version

- name: Install dependencies
run: poetry install

- name: Lint
run: ./scripts/lint.sh
# Temporaryly disabled due to circular depencies
# - name: Lint
# run: ./scripts/lint.sh
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version

- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"

- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2.0.2
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"

- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)

- name: Build package
run: |
poetry build --ansi

- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.21.1
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 changes: 0 additions & 66 deletions .github/workflows/test.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Test

on: [push, pull_request]

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python: ["3.6", "3.7", "3.8", "3.9", "3.10"]
os: [ubuntu-latest, ubuntu-18.04, macos-latest, windows-latest]

steps:
- name: Check out the repository
uses: actions/checkout@v3

# Clean poisoned cache
# - name: Ubuntu cache
# uses: actions/cache@v2
# if: startsWith(matrix.os, 'ubuntu')
# with:
# path: ~/.cache/pip
# key:
# ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
# restore-keys: |
# ${{ matrix.os }}-${{ matrix.python }}-

# - name: macOS cache
# uses: actions/cache@v2
# if: startsWith(matrix.os, 'macOS')
# with:
# path: ~/Library/Caches/pip
# key:
# ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
# restore-keys: |
# ${{ matrix.os }}-${{ matrix.python }}-

# - name: Windows cache
# uses: actions/cache@v2
# if: startsWith(matrix.os, 'windows')
# with:
# path: c:\users\runneradmin\appdata\local\pip\cache
# key:
# ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
# restore-keys: |
# ${{ matrix.os }}-${{ matrix.python }}-

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version

- name: Install dependencies
run: poetry install

- name: Test
shell: bash
run: |
poetry run pytest tests/unit/ -s --cov=isort/ --cov-report=term-missing ${@-}
poetry run coverage xml

- name: Report Coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v1
Loading