From 568fd5c1837632f0457d71dfa38d8673d7cea11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Fri, 24 Nov 2023 14:12:57 +0100 Subject: [PATCH 1/5] cleanup github actions --- .github/workflows/deploy.yml | 1 - .github/workflows/minimal.yml | 16 +++----------- .github/workflows/notebooks.yml | 11 +++------- .github/workflows/pypicheck.yml | 5 +---- .github/workflows/unittests.yml | 30 +++++++++----------------- .github/workflows/unittests_abinit.yml | 16 ++++---------- .github/workflows/unittests_gpaw.yml | 13 ++--------- .github/workflows/unittests_qe.yml | 16 ++++---------- .github/workflows/unittests_siesta.yml | 16 ++++---------- 9 files changed, 31 insertions(+), 93 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 92e6a3e1..239cc692 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,6 @@ jobs: - uses: actions/setup-python@v2 with: python-version: "3.11" - - name: Install dependencies run: >- python -m pip install --user --upgrade setuptools wheel diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml index fc2a8364..cf55e546 100644 --- a/.github/workflows/minimal.yml +++ b/.github/workflows/minimal.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -24,16 +19,11 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f .ci_support/environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 run: | - coverage run --omit atomistics/_version.py -m unittest discover tests - coverage combine + pip install --no-deps . + python -m unittest discover tests diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index ec07a809..288d033e 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -10,9 +10,7 @@ on: jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Merge Notebook environment @@ -26,13 +24,10 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup + - name: Test shell: bash -l {0} run: | pip install --no-deps . - - name: Test - shell: bash -l {0} - run: ./.ci_support/build_notebooks.sh \ No newline at end of file + ./.ci_support/build_notebooks.sh \ No newline at end of file diff --git a/.github/workflows/pypicheck.yml b/.github/workflows/pypicheck.yml index 81be7a38..1176e4a6 100644 --- a/.github/workflows/pypicheck.yml +++ b/.github/workflows/pypicheck.yml @@ -10,9 +10,7 @@ on: jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Setup Mambaforge @@ -23,9 +21,8 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: .ci_support/environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f .ci_support/environment.yml - name: Pip check shell: bash -l {0} run: | diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 17998c63..ec101c82 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ${{ matrix.operating-system }} strategy: matrix: @@ -44,6 +39,14 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Setup environment (windows) + if: matrix.operating-system == 'windows-latest' + run: cp .ci_support/environment.yml environment.yml + - name: Setup environment (unix) + if: matrix.operating-system != 'windows-latest' + shell: bash -l {0} + run: | + python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-lammps.yml > environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: @@ -52,26 +55,13 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Setup environment (windows) - if: matrix.operating-system == 'windows-latest' - run: cp .ci_support/environment.yml environment.yml - - name: Setup environment (unix) - if: matrix.operating-system != 'windows-latest' - shell: bash -l {0} - run: | - mamba install -y pyyaml - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-lammps.yml > environment.yml - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 run: | + pip install --no-deps . coverage run --omit atomistics/_version.py -m unittest discover tests coverage combine - name: Coveralls diff --git a/.github/workflows/unittests_abinit.yml b/.github/workflows/unittests_abinit.yml index 4e093adb..110d62ab 100644 --- a/.github/workflows/unittests_abinit.yml +++ b/.github/workflows/unittests_abinit.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,17 +22,14 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 - run: python -m unittest tests/test_evcurve_abinit.py + run: | + pip install --no-deps . + python -m unittest tests/test_evcurve_abinit.py env: ABINIT_PP_PATH: '/usr/share/miniconda3/envs/my-env/share/abinit/LDA_FHI' ABI_PSPDIR: '/usr/share/miniconda3/envs/my-env/share/abinit/LDA_FHI' diff --git a/.github/workflows/unittests_gpaw.yml b/.github/workflows/unittests_gpaw.yml index d6f00c1c..240e4ad5 100644 --- a/.github/workflows/unittests_gpaw.yml +++ b/.github/workflows/unittests_gpaw.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,17 +22,13 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 run: | + pip install --no-deps . python -m unittest tests/test_evcurve_gpaw.py python -m unittest tests/test_elastic_gpaw.py python -m unittest tests/test_phonons_gpaw.py diff --git a/.github/workflows/unittests_qe.yml b/.github/workflows/unittests_qe.yml index b28a20ce..91bced01 100644 --- a/.github/workflows/unittests_qe.yml +++ b/.github/workflows/unittests_qe.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,17 +22,14 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 - run: python -m unittest tests/test_evcurve_qe.py + run: | + pip install --no-deps . + python -m unittest tests/test_evcurve_qe.py env: ASE_ESPRESSO_COMMAND: "mpirun -np 1 pw.x -in PREFIX.pwi > PREFIX.pwo" ESPRESSO_PSEUDO: tests/static/qe diff --git a/.github/workflows/unittests_siesta.yml b/.github/workflows/unittests_siesta.yml index 503fe1f5..a558c2a7 100644 --- a/.github/workflows/unittests_siesta.yml +++ b/.github/workflows/unittests_siesta.yml @@ -6,13 +6,8 @@ on: pull_request: branches: [ main ] -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,14 +22,11 @@ jobs: channels: conda-forge channel-priority: strict activate-environment: my-env + environment-file: environment.yml use-mamba: true - - name: Update environment - run: mamba env update -n my-env -f environment.yml - - name: Setup - shell: bash -l {0} - run: | - pip install --no-deps . - name: Test shell: bash -l {0} timeout-minutes: 30 - run: python -m unittest tests/test_evcurve_siesta.py \ No newline at end of file + run: | + pip install --no-deps . + python -m unittest tests/test_evcurve_siesta.py \ No newline at end of file From 3b9e45b1a26d3d023c98cddcc8b7f862b05c7a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Fri, 24 Nov 2023 14:28:56 +0100 Subject: [PATCH 2/5] merge environment files in bash --- .ci_support/condamerge.py | 57 --------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .ci_support/condamerge.py diff --git a/.ci_support/condamerge.py b/.ci_support/condamerge.py deleted file mode 100644 index fb2df69e..00000000 --- a/.ci_support/condamerge.py +++ /dev/null @@ -1,57 +0,0 @@ -import argparse -import sys -import yaml - - -def read_file(path): - with open(path) as f: - return yaml.safe_load(f) - - -def parse_args(argv=None): - parser = argparse.ArgumentParser() - parser.add_argument('--base', dest='base', help='base environment.yml file') - parser.add_argument('--add', dest='add', help='addon environment.yml file') - return parser.parse_args(argv) - - -def merge_dependencies(env_base, env_add): - base_dict = {f.split()[0]: f for f in env_base} - add_dict = {f.split()[0]: f for f in env_add} - for k,v in add_dict.items(): - if k not in base_dict.keys(): - base_dict[k] = v - return list(base_dict.values()) - - -def merge_channels(env_base, env_add): - for c in env_add: - if c not in env_base: - env_base.append(c) - return env_base - - -def merge_env(env_base, env_add): - return { - "channels": merge_channels( - env_base=env_base['channels'], - env_add=env_add['channels'] - ), - 'dependencies': merge_dependencies( - env_base=env_base['dependencies'], - env_add=env_add['dependencies'] - ) - } - - -if __name__ == '__main__': - arguments = parse_args(argv=None) - yaml.dump( - merge_env( - env_base=read_file(arguments.base), - env_add=read_file(arguments.add) - ), - sys.stdout, - indent=2, - default_flow_style=False - ) From e4969687fe1f411e6dcbb014d59ac0c8465d3e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Fri, 24 Nov 2023 14:29:14 +0100 Subject: [PATCH 3/5] merge actions --- .github/workflows/notebooks.yml | 3 ++- .github/workflows/unittests.yml | 3 ++- .github/workflows/unittests_abinit.yml | 3 ++- .github/workflows/unittests_gpaw.yml | 3 ++- .github/workflows/unittests_qe.yml | 3 ++- .github/workflows/unittests_siesta.yml | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index 288d033e..45ec5e01 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -15,7 +15,8 @@ jobs: - uses: actions/checkout@v2 - name: Merge Notebook environment run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-notebooks.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-abinit.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index ec101c82..f3786395 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -46,7 +46,8 @@ jobs: if: matrix.operating-system != 'windows-latest' shell: bash -l {0} run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-lammps.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-lammps.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests_abinit.yml b/.github/workflows/unittests_abinit.yml index 110d62ab..36ababcf 100644 --- a/.github/workflows/unittests_abinit.yml +++ b/.github/workflows/unittests_abinit.yml @@ -13,7 +13,8 @@ jobs: - uses: actions/checkout@v2 - name: Merge Notebook environment run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-abinit.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-abinit.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests_gpaw.yml b/.github/workflows/unittests_gpaw.yml index 240e4ad5..dbf0b67a 100644 --- a/.github/workflows/unittests_gpaw.yml +++ b/.github/workflows/unittests_gpaw.yml @@ -13,7 +13,8 @@ jobs: - uses: actions/checkout@v2 - name: Merge Notebook environment run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-gpaw.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-abinit.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests_qe.yml b/.github/workflows/unittests_qe.yml index 91bced01..a2c3041d 100644 --- a/.github/workflows/unittests_qe.yml +++ b/.github/workflows/unittests_qe.yml @@ -13,7 +13,8 @@ jobs: - uses: actions/checkout@v2 - name: Merge Notebook environment run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-qe.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-abinit.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests_siesta.yml b/.github/workflows/unittests_siesta.yml index a558c2a7..3e5e20d3 100644 --- a/.github/workflows/unittests_siesta.yml +++ b/.github/workflows/unittests_siesta.yml @@ -13,7 +13,8 @@ jobs: - uses: actions/checkout@v2 - name: Merge Notebook environment run: | - python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-siesta.yml > environment.yml + cp .ci_support/environment.yml environment.yml + tail --lines=+4 .ci_support/environment-abinit.yml >> environment.yml - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: From 993d53a7148b3ce8e6ecead918acead5524e1b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Fri, 24 Nov 2023 14:34:38 +0100 Subject: [PATCH 4/5] Update checkout action --- .github/workflows/black.yml | 2 +- .github/workflows/dependabot.yml | 2 +- .github/workflows/deploy.yml | 6 +++--- .github/workflows/minimal.yml | 2 +- .github/workflows/notebooks.yml | 2 +- .github/workflows/pypicheck.yml | 2 +- .github/workflows/unittests.yml | 2 +- .github/workflows/unittests_abinit.yml | 2 +- .github/workflows/unittests_gpaw.yml | 2 +- .github/workflows/unittests_qe.yml | 2 +- .github/workflows/unittests_siesta.yml | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 9f5d698e..572a0e26 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: psf/black@stable with: options: "--check --diff" diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index f6a2c2d3..17897a2a 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest if: (github.actor == 'dependabot[bot]') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR fetch-depth: 0 # otherwise, you will fail to push refs to dest repo diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 239cc692..f567fa45 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,12 +14,12 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/atomistics + url: https://pypi.org/p/${{ github.event.repository.name }} permissions: id-token: write steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: python-version: "3.11" - name: Install dependencies diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml index cf55e546..a63e5f40 100644 --- a/.github/workflows/minimal.yml +++ b/.github/workflows/minimal.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index 45ec5e01..e9acc01a 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Merge Notebook environment run: | cp .ci_support/environment.yml environment.yml diff --git a/.github/workflows/pypicheck.yml b/.github/workflows/pypicheck.yml index 1176e4a6..eb187749 100644 --- a/.github/workflows/pypicheck.yml +++ b/.github/workflows/pypicheck.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index f3786395..fb9b31b1 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -38,7 +38,7 @@ jobs: prefix: /usr/share/miniconda3/envs/my-env steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup environment (windows) if: matrix.operating-system == 'windows-latest' run: cp .ci_support/environment.yml environment.yml diff --git a/.github/workflows/unittests_abinit.yml b/.github/workflows/unittests_abinit.yml index 36ababcf..30bd16a2 100644 --- a/.github/workflows/unittests_abinit.yml +++ b/.github/workflows/unittests_abinit.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Merge Notebook environment run: | cp .ci_support/environment.yml environment.yml diff --git a/.github/workflows/unittests_gpaw.yml b/.github/workflows/unittests_gpaw.yml index dbf0b67a..d52292e7 100644 --- a/.github/workflows/unittests_gpaw.yml +++ b/.github/workflows/unittests_gpaw.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Merge Notebook environment run: | cp .ci_support/environment.yml environment.yml diff --git a/.github/workflows/unittests_qe.yml b/.github/workflows/unittests_qe.yml index a2c3041d..c0b9e009 100644 --- a/.github/workflows/unittests_qe.yml +++ b/.github/workflows/unittests_qe.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Merge Notebook environment run: | cp .ci_support/environment.yml environment.yml diff --git a/.github/workflows/unittests_siesta.yml b/.github/workflows/unittests_siesta.yml index 3e5e20d3..71e3daa8 100644 --- a/.github/workflows/unittests_siesta.yml +++ b/.github/workflows/unittests_siesta.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Merge Notebook environment run: | cp .ci_support/environment.yml environment.yml From d582991a7b2c8df4f26f5ba0d9feb508122080ac Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Fri, 24 Nov 2023 14:47:13 +0100 Subject: [PATCH 5/5] Create format_black.yml --- .github/workflows/format_black.yml | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/format_black.yml diff --git a/.github/workflows/format_black.yml b/.github/workflows/format_black.yml new file mode 100644 index 00000000..f7a62e5d --- /dev/null +++ b/.github/workflows/format_black.yml @@ -0,0 +1,33 @@ +# This workflow will checkout the branch of the PR, apply black formatting and commit the result to the PR. Does not work for forks. + +name: Format black + +on: + pull_request: + types: [labeled] + +jobs: + build: + if: contains(github.event.pull_request.labels.*.name, 'format_black' ) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }} + ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR + fetch-depth: 0 # otherwise, you will fail to push refs to dest repo + - name: format black + uses: psf/black@stable + with: + options: "" + src: "./${{ github.event.repository.name }}" + - name: commit + run: | + git config --local user.email "pyiron@mpie.de" + git config --local user.name "pyiron-runner" + git commit -m "Format black" -a + - name: push + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }} + branch: ${{ github.event.pull_request.head.ref }}