Skip to content

Commit

Permalink
Run black on main only
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed May 2, 2023
1 parent 3014e3f commit 89c6763
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 49 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/all_green_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ on: # yamllint disable-line rule:truthy
- '*'

jobs:
changelog:
uses: ./.github/workflows/changelog.yml # use the callable changelog job to run tests
linters:
uses: ./.github/workflows/linters.yml # use the callable linters job to run tests
changelog-and-linters:
uses: ./.github/workflows/changelog_and_linters.yml # use the callable changelog-and-linters job to run tests
sanity:
uses: ./.github/workflows/sanity.yml # use the callable sanity job to run tests
units:
Expand All @@ -38,8 +36,7 @@ jobs:
steps:
- run: >-
python -c "assert set([
'${{ needs.changelog.result }}',
'${{ needs.changelog-and-linters.result }}',
'${{ needs.sanity.result }}',
'${{ needs.linters.result }}',
'${{ needs.units.result }}'
]) == {'success'}"
58 changes: 48 additions & 10 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
---
name: black

concurrency:
group: '${{ github.workflow }} @ ${{ github.sha }}'
cancel-in-progress: true
name: 'Python formatting linter (Black)'

on:
push:
workflow_dispatch:
pull_request:
branches:
- main
- 'stable-*'
pull_request_target:

permissions:
contents: read
pull-requests: read

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
format:
uses: abikouo/github_actions/.github/workflows/black.yml@automate_changes_a
check-black:
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Checkout the collection repository
uses: actions/checkout@v3
with:
path: ${{ env.source_directory }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: "0"

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

- name: Read collection metadata from galaxy.yml
id: identify
uses: ansible-network/github_actions/.github/actions/identify_collection@main
with:
source_path: ${{ env.source_directory }}

- name: Build and install the collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: false
source_path: ${{ env.source_directory }}
collection_path: ${{ steps.identify.outputs.collection_path }}
tar_file: ${{ steps.identify.outputs.tar_file }}

- name: Install black
run: pip install black

- name: Run black
run: |
black -v --check --diff .
working-directory: ${{ steps.identify.outputs.collection_path }}
8 changes: 0 additions & 8 deletions .github/workflows/changelog.yml

This file was deleted.

25 changes: 0 additions & 25 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,3 @@ deps =
flake8>=3.3.0,<5.0.0
flake8-html
commands = -flake8 --select C90 --max-complexity 10 --format=html --htmldir={posargs:complexity} plugins

[testenv:black_check]
deps =
black >=23.0, <24.0

commands =
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests

[testenv:black]
deps =
{[testenv:black_check]deps}

commands =
black -v {posargs:{toxinidir}/plugins {toxinidir}/tests}

[testenv:linters]
deps =
yamllint
flake8
{[testenv:black_check]deps}

commands =
{[testenv:black_check]commands}
yamllint -s {toxinidir}
flake8 {toxinidir}

0 comments on commit 89c6763

Please sign in to comment.