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

ci: update test scripts to use install-poetry.py and cleanup release workflow #168

Merged
merged 2 commits into from
Apr 11, 2021
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
139 changes: 31 additions & 108 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,125 +6,48 @@ on:
- '*.*.*'

jobs:

Linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Get tag
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install and set up Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
- name: Build distributions
run: |
source $HOME/.poetry/env
poetry build -vvv
- name: Upload distribution artifacts
uses: actions/upload-artifact@v1
with:
name: pendulum-dist
path: dist

MacOS:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Get tag
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install and set up Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
- name: Build distributions
run: |
source $HOME/.poetry/env
poetry build -vvv
- name: Upload distribution artifacts
uses: actions/upload-artifact@v1
with:
name: pendulum-dist
path: dist

Windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Get tag
id: tag
shell: bash
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install and setup Poetry
run: |
Invoke-WebRequest https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -O get-poetry.py
python get-poetry.py --preview -y
- name: Build distributions
run: |
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry build -vvv
- name: Upload distribution artifact
uses: actions/upload-artifact@v1
with:
name: pendulum-dist
path: dist

Release:
needs: [Linux, MacOS, Windows]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get tag
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Download distribution artifact
uses: actions/download-artifact@master
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
name: pendulum-dist
path: dist
- name: Install and set up Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
- name: Check distributions
python-version: "3.9"

- name: Install Poetry
run: |
ls -la dist
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \
| python - -y

- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build project for distribution
run: poetry build

- name: Check Version
id: check-version
run: |
source $HOME/.poetry/env
poetry publish
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
|| echo ::set-output name=prerelease::true

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
uses: ncipollo/release-action@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: ${{ steps.tag.outputs.tag }}
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
prerelease: steps.check-version.outputs.prerelease == 'true'

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
31 changes: 23 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ on:
branches: [master]

jobs:
Tests:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
runs-on: "${{ matrix.os }}-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: [3.6, 3.7, 3.8, 3.9]
experimental: [false]
bootstrap-args: [""]
include:
- os: Ubuntu
python-version: pypy3
experimental: false
- os: Ubuntu
python-version: "3.10.0-alpha - 3.10.0"
experimental: true
bootstrap-args: "--git https://github.com/python-poetry/poetry.git"
fail-fast: false
steps:
- uses: actions/checkout@v2

Expand All @@ -30,21 +33,33 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Get full python version
- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install poetry
- name: Bootstrap poetry
shell: bash
run: pip install poetry
run: |
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \
| python - -y ${{ matrix.bootstrap-args }}

- name: Update PATH
if: ${{ matrix.os != 'Windows' }}
shell: bash
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update Path for Windows
if: ${{ matrix.os == 'Windows' }}
shell: bash
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH

- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v1
uses: actions/cache@v2
id: cache
with:
path: .venv
Expand All @@ -53,12 +68,12 @@ jobs:
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: timeout 10s poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
shell: bash
run: poetry install

- name: Run pytest
shell: bash
run: poetry run pytest -q tests
run: poetry run python -m pytest -p no:sugar -q tests/