Skip to content

Commit

Permalink
update actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmathis committed Sep 18, 2024
1 parent 0032dc0 commit 1807747
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5,420 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/check-enums.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: check-enums

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write

jobs:
check-enums:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip

- name: Install dependencies
run: |
pip install --upgrade pip pip-tools black ruamel.yaml
pip install --user --no-deps -e ./emmet-core
- name: Generate enums and check output
id: enums
shell: bash -l {0}
run: |
set -e
python emmet-core/dev_scripts/generate_enums.py
black emmet-core/emmet/core/*/calc_types/enums.py
echo "count=$(git diff --exit-code --quiet HEAD emmet-core/emmet/core/*/calc_types/enums.py || echo "1")" >> $GITHUB_OUTPUT
echo "files=$(git ls-files --exclude-standard --others emmet-core/emmet/core/*/calc_types/enums.py | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: Commit & push enums changes
shell: bash -l {0}
run: |
set -e
if [[ "${{ steps.enums.outputs.count }}" > 0 || "${{ steps.enums.outputs.files }}" > 0 ]]; then
git config user.name github-actions
git config user.email [email protected]
git add emmet-core/emmet/core/*/calc_types/enums.py
git commit --allow-empty -m "[automated commit] update calc type enums"
git push
else
echo "No changes detected in enum files."
fi
9 changes: 5 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Linting

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
workflow_run:
workflows: ["check-enums"]
types: [completed]

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v4

Expand Down
40 changes: 9 additions & 31 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
name: testing

on:
workflow_dispatch: # Allow running on-demand

push:
branches:
- main

pull_request:
branches:
- main
workflow_dispatch:
workflow_run:
workflows: ["check-enums"]
types: [completed]

jobs:
test:
name: ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
os: ["ubuntu-latest"] # TODO openbabel for windows and mac
Expand All @@ -39,30 +35,12 @@ jobs:
- name: Install Python dependencies
shell: bash -l {0}
run: |
python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools pre-commit
python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools
python${{ matrix.python-version }} -m pip install --user `grep numpy ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m pip install --user -r ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt
- name: generate Enums
id: enums
shell: bash -l {0}
if: matrix.package == 'emmet-core'
run: |
python${{ matrix.python-version }} emmet-core/emmet/core/qchem/calc_types/generate.py
python${{ matrix.python-version }} emmet-core/emmet/core/vasp/calc_types/generate.py
pre-commit run --all-files --show-diff-on-failure
echo "count=$(git diff-index HEAD emmet-core/emmet/core/*/calc_types/enums.py | wc -l | xargs)" >> $GITHUB_OUTPUT
echo "files=$(git ls-files --exclude-standard --others emmet-core/emmet/core/*/calc_types/enums.py | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: commit & push enums changes
if: matrix.package == 'emmet-core' && (steps.enums.outputs.count > 0 || steps.enums.outputs.files > 0)
shell: bash -l {0}
run: |
git config user.name github-actions
git config user.email [email protected]
git add emmet-core/emmet/core/*/calc_types/enums.py
git commit --allow-empty -m "update calc type enums"
git push origin ${{ github.ref_name }}
env:
CC: gcc-10
CXX: g++-10

- name: Install editable emmet-core if needed
shell: bash -l {0}
Expand Down
Loading

0 comments on commit 1807747

Please sign in to comment.