Skip to content

Commit

Permalink
Merge branch 'main' into alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
HowWeiBin authored Apr 9, 2024
2 parents 713c963 + f15f358 commit 508b8c1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ on:
- cron: '0 8 * * 1' # run every Monday at 8am UTC

jobs:
setup:
runs-on: ubuntu-latest
outputs:
examplesmatrix: ${{ steps.collectExamples.outputs.examplesjson }}
steps:
- uses: actions/checkout@v4

- id: collectExamples
run: |
echo examplesjson=$(./developer/get_examples.py) >> $GITHUB_OUTPUT
generate-example:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -22,7 +34,6 @@ jobs:
- batch-cp2k
- lpr
- dos-align

steps:
- uses: actions/checkout@v4

Expand Down
25 changes: 25 additions & 0 deletions developer/get_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
"""Script to create JSON string suitable for a github action matrix."""
import glob
import json
import os


ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
EXAMPLES = os.path.join(ROOT, "examples")


def get_examples():
"""The current list of examples, determined from the directories on disk"""
return [
os.path.basename(os.path.normpath(file)) for file in glob.glob(f"{EXAMPLES}/*")
]


def create_json():
"""A JSON string suitable for a github action matrix."""
return json.dumps({"example-name": get_examples()})


if __name__ == "__main__":
print(create_json())
13 changes: 9 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import hashlib
import json
import os
import sys

import nox


ROOT = os.path.realpath(os.path.dirname(__file__))

sys.path.append(ROOT)
from developer.get_examples import get_examples # noqa: E402


# global nox options
nox.needs_version = ">=2024"
nox.options.reuse_venv = "yes"
Expand All @@ -19,12 +26,10 @@
"noxfile.py",
"docs/src/conf.py",
"examples",
"developer",
]

# the current list of examples, determined from the directories on disk
EXAMPLES = [
os.path.basename(os.path.normpath(file)) for file in glob.glob("examples/*/")
]
EXAMPLES = get_examples()

# ==================================================================================== #
# helper functions #
Expand Down

0 comments on commit 508b8c1

Please sign in to comment.