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

Consolidate test and release workflows + add concurrency limit to test + fuzz #3017

Closed
wants to merge 2 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
53 changes: 0 additions & 53 deletions .github/workflows/docker.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Fuzz

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
build:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Publish

on:
push:
branches: [main]
release:
types: [published]

jobs:
pypi:
name: PyPI (sdist + pure wheel)
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3

- name: Install latest pip, build, twine
run: |
python -m pip install --upgrade --disable-pip-version-check pip
python -m pip install --upgrade build twine

- name: Build wheel and source distributions
run: |
python -m build

- name: Upload to PyPI via Twine
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload --verbose -u '__token__' dist/*

native-binaries:
needs: [pypi]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-20.04, macos-latest]
include:
- os: windows-2019
pathsep: ";"
asset_name: black_windows.exe
executable_mime: "application/vnd.microsoft.portable-executable"
- os: ubuntu-20.04
pathsep: ":"
asset_name: black_linux
executable_mime: "application/x-executable"
- os: macos-latest
pathsep: ":"
asset_name: black_macos
executable_mime: "application/x-mach-binary"

steps:
- uses: actions/checkout@v3

- name: Set up latest Python
uses: actions/setup-python@v3
with:
python-version: "*"

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install .
python -m pip install pyinstaller

- name: Build binary
run: |
python -m PyInstaller -F --name ${{ matrix.asset_name }} --add-data 'src/blib2to3${{ matrix.pathsep }}blib2to3' src/black/__main__.py

- name: Upload binary as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/${{ matrix.asset_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: ${{ matrix.executable_mime }}

docker:
if: github.repository == 'psf/black'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Check + set version tag
run:
echo "GIT_TAG=$(git describe --candidates=0 --tags 2> /dev/null || echo
latest_non_release)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: pyfound/black:latest,pyfound/black:${{ env.GIT_TAG }}

- name: Build and push latest_release tag
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: pyfound/black:latest_release
31 changes: 0 additions & 31 deletions .github/workflows/pypi_upload.yml

This file was deleted.

33 changes: 31 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ on:
- "docs/**"
- "*.md"

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

jobs:
build:
main:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
Expand Down Expand Up @@ -66,7 +70,7 @@ jobs:
debug: true

coveralls-finish:
needs: build
needs: main
# If pushed / is a pull request against main repo
if:
(github.event_name == 'push' && github.repository == 'psf/black') ||
Expand All @@ -80,3 +84,28 @@ jobs:
with:
parallel-finished: true
debug: true

uvloop:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v3

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

- name: Install latest pip
run: |
python -m pip install --upgrade pip

- name: Test uvloop Extra Install
run: |
python -m pip install -e ".[uvloop]"

- name: Format ourselves
run: |
python -m black --check src/
54 changes: 0 additions & 54 deletions .github/workflows/upload_binary.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/uvloop_test.yml

This file was deleted.

Loading