upload to prod pypi from workflow (#697)

This commit is contained in:
Zsolt Dollenstein 2022-06-13 18:27:07 +01:00 committed by GitHub
parent ebe1851c2b
commit 66676aaeec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 281 additions and 256 deletions

View file

@ -1,154 +1,9 @@
name: Python CI
name: build
on:
push:
branches:
- main
pull_request:
workflow_call:
jobs:
# Run unittests
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
parser: [pure, native]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- if: ${{ matrix.parser == 'native' }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- if: ${{ matrix.parser == 'native' }}
name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
with:
working-directory: native
- run: >-
echo LIBCST_PARSER_TYPE=${{ matrix.parser }} >> $GITHUB_ENV
- name: Run Tests
run: python setup.py test
# Run linters
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- run: flake8
- run: ufmt check .
- run: python3 -m fixit.cli.run_rules
- run: python -m slotscheck libcst
- run: ./check_copyright.sh
# Run pyre typechecker
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Make sure Pyre uses the working copy
run: pip install -e .
- run: pyre --version
- run: pyre -n check
- run: python libcst/tests/test_pyre_integration.py
- run: git diff --exit-code
# Upload test coverage
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Generate Coverage
run: |
coverage run setup.py test
coverage xml -i
- uses: codecov/codecov-action@v2
with:
files: coverage.xml
fail_ci_if_error: true
verbose: true
- name: Archive Coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml
# Build the docs
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- uses: ts-graphviz/setup-graphviz@v1
- run: sphinx-build docs/source/ docs/build/
- name: Archive Docs
uses: actions/upload-artifact@v2
with:
name: sphinx-docs
path: docs/build
# Build python wheels
# Build python wheels
build_matrix:
name: Prepare job matrix for build job
runs-on: ubuntu-latest
@ -183,126 +38,30 @@ jobs:
CIBW_SKIP: "cp27-* cp34-* cp35-* pp* *-win32 *-win_arm64 *-musllinux_*"
CIBW_ARCHS: ${{ matrix.vers }}
CIBW_BUILD_VERBOSITY: 1
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
if: ${{ !contains(matrix.os, 'self-hosted') }}
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
if: ${{ !contains(matrix.os, 'self-hosted') }}
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Rust Cache
if: ${{ !contains(matrix.os, 'self-hosted') }}
uses: Swatinem/rust-cache@v1.3.0
with:
working-directory: native
- name: Disable scmtools local scheme
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: >-
echo LIBCST_NO_LOCAL_SCHEME=1 >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
- uses: actions/upload-artifact@v2
with:
path: wheelhouse/*.whl
name: wheels
pypi:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Upload wheels to pypi
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v1
- name: Download binary wheels
id: download
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- uses: actions/setup-python@v2
if: ${{ !contains(matrix.os, 'self-hosted') }}
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
if: ${{ !contains(matrix.os, 'self-hosted') }}
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Disable scmtools local scheme
run: >-
echo LIBCST_NO_LOCAL_SCHEME=1 >> $GITHUB_ENV
- name: Build a source tarball
run: >-
python -m
build
--sdist
--outdir ${{ steps.download.outputs.download-path }}
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: ${{ steps.download.outputs.download-path }}
# Test rust parts
native:
name: Rust unit tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Rust Cache
if: ${{ !contains(matrix.os, 'self-hosted') }}
uses: Swatinem/rust-cache@v1.3.0
with:
working-directory: native
- uses: actions/setup-python@v2
- name: Disable scmtools local scheme
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: >-
echo LIBCST_NO_LOCAL_SCHEME=1 >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
- uses: actions/upload-artifact@v2
with:
python-version: "3.10"
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=native/Cargo.toml --release
- name: test without python
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=native/Cargo.toml --release --no-default-features
- name: clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path=native/Cargo.toml --all-features
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path=native/Cargo.toml -- --check
path: wheelhouse/*.whl
name: wheels

203
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,203 @@
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
# Run unittests
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
parser: [pure, native]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- if: ${{ matrix.parser == 'native' }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- if: ${{ matrix.parser == 'native' }}
name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
with:
working-directory: native
- run: >-
echo LIBCST_PARSER_TYPE=${{ matrix.parser }} >> $GITHUB_ENV
- name: Run Tests
run: python setup.py test
# Run linters
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- run: flake8
- run: ufmt check .
- run: python3 -m fixit.cli.run_rules
- run: python -m slotscheck libcst
- run: ./check_copyright.sh
# Run pyre typechecker
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Make sure Pyre uses the working copy
run: pip install -e .
- run: pyre --version
- run: pyre -n check
- run: python libcst/tests/test_pyre_integration.py
- run: git diff --exit-code
# Upload test coverage
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Generate Coverage
run: |
coverage run setup.py test
coverage xml -i
- uses: codecov/codecov-action@v2
with:
files: coverage.xml
fail_ci_if_error: true
verbose: true
- name: Archive Coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml
# Build the docs
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- uses: ts-graphviz/setup-graphviz@v1
- run: sphinx-build docs/source/ docs/build/
- name: Archive Docs
uses: actions/upload-artifact@v2
with:
name: sphinx-docs
path: docs/build
# Test rust parts
native:
name: Rust unit tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
with:
working-directory: native
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=native/Cargo.toml --release
- name: test without python
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=native/Cargo.toml --release --no-default-features
- name: clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path=native/Cargo.toml --all-features
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path=native/Cargo.toml -- --check

63
.github/workflows/pypi_upload.yml vendored Normal file
View file

@ -0,0 +1,63 @@
name: pypi_upload
on:
release:
types: [published]
push:
branches: [main]
permissions:
contents: read
jobs:
build:
uses: Instagram/LibCST/.github/workflows/build.yml@main
upload_release:
name: Upload wheels to pypi
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v1
- name: Download binary wheels
id: download
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt', 'setup.py') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
- name: Disable scmtools local scheme
run: >-
echo LIBCST_NO_LOCAL_SCHEME=1 >> $GITHUB_ENV
- name: Build a source tarball
run: >-
python -m
build
--sdist
--outdir ${{ steps.download.outputs.download-path }}
- name: Publish distribution 📦 to Test PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: ${{ steps.download.outputs.download-path }}
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://pypi.org/legacy/
packages_dir: ${{ steps.download.outputs.download-path }}