Pseudo Validate GHA Output #875
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pseudo Validate GHA Output | |
# Approximation of the GHA "on" block | |
on: | |
# GitHub has started calling new repo's first branch "main" https://github.com/github/renaming | |
# The cookiecutter uses the "--initial-branch" flag when it runs git-init | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
- "review23" | |
schedule: | |
# Nightly tests run on main by default: | |
# Scheduled workflows run on the latest commit on the default or base branch. | |
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule) | |
- cron: "0 0 * * 0" | |
# Custom global env block (Has to be recreated in each matrix, can't pass sequences to this) | |
env: # I want to share these between jobs, but I can't access the env from inside matrix, has to be on the steps. | |
licenses: "1 2" | |
depend-sources: "1 2 3" | |
rtd: "1 2" | |
jobs: | |
generate-cookiecutter: | |
name: "Cookiecutter Artifacts" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
python-version: [3.9, "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: "Install dependencies" | |
shell: bash | |
run: | | |
python -m pip install -U pyyaml cookiecutter | |
- name: "Construct Cookiecutter" | |
shell: bash | |
run: | | |
mkdir artifact_upload # Uploading artifact directory uploads as "path/*" rather than "path", so stage the upload. | |
for LIC in ${{ env.licenses }} | |
do | |
for DEP in ${{ env.depend-sources }} | |
do | |
for RTD in ${{ env.rtd }} | |
do | |
COMBO="$LIC"_"$DEP"_"$RTD" | |
python tests/setup_cookiecutter.py prj_$COMBO $LIC $DEP $RTD | |
mv prj_$COMBO artifact_upload/prj_$COMBO | |
done | |
done | |
done | |
- name: "Upload artifacts" | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 }} # Upload only if ubuntu and latest python (only need to run once) | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cookiecutter_outputs | |
path: artifact_upload | |
compare-action-output: | |
name: "Compare GHA Output" | |
runs-on: ubuntu-latest | |
needs: "generate-cookiecutter" | |
strategy: | |
matrix: | |
license: [1, 2] | |
depend-source: [1, 2, 3] | |
rtd: [1, 2] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Fetch Artifacts" | |
uses: actions/download-artifact@v2 | |
with: | |
name: cookiecutter_outputs | |
- name: "Compare Reference CI" | |
shell: bash | |
run: | | |
COMBO="${{ matrix.license }}_${{ matrix.depend-source }}_${{ matrix.rtd }}" | |
mv prj_$COMBO/.github/workflows/CI.yaml CI_$COMBO.yaml | |
COMPARE=$(diff CI_$COMBO.yaml .github/reference-workflows/CI_$COMBO.yaml) | |
if [[ ! -z $COMPARE ]] | |
then | |
echo "CI_$COMBO.yaml differs from reference!" | |
echo $COMPARE | |
exit 1 | |
fi | |
conda-forge-dep: | |
needs: "generate-cookiecutter" | |
name: Test CF (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: # Approximate strategy, uses a few other options | |
matrix: | |
os: [ubuntu-latest , macOS-latest, windows-latest] | |
python-version: [3.9, "3.10", "3.11"] | |
license: [1] # Nonstandard | |
rtd: [1, 2] # Nonstandard | |
steps: | |
# - uses: actions/checkout@v4 # This isn't necessary here | |
- name: "Fetch Artifacts" | |
uses: actions/download-artifact@v2 | |
with: | |
name: cookiecutter_outputs | |
- name: Additional info about the build | |
shell: bash | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
# - name: "Change directory" # Have to CD here to make sure this works | |
# shell: bash | |
# run: | | |
# cd prj_${{ matrix.license }}_1_${{ matrix.rtd }} | |
# More info on options: https://github.com/marketplace/actions/setup-micromamba | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: prj_${{ matrix.license }}_1_${{ matrix.rtd }}/devtools/conda-envs/test_env.yaml | |
environment-name: test | |
create-args: >- | |
python=${{ matrix.python-version }} | |
condarc: | | |
channels: | |
- conda-forge | |
- name: Install package | |
# conda setup requires this special shell | |
shell: bash -l {0} | |
working-directory: prj_${{ matrix.license }}_1_${{ matrix.rtd }} # Nonstandard | |
run: | | |
python -m pip install . --no-deps | |
micromamba list | |
- name: Run tests | |
# conda setup requires this special shell | |
shell: bash -l {0} | |
working-directory: prj_${{ matrix.license }}_1_${{ matrix.rtd }} # Nonstandard | |
run: | | |
pytest -v --cov=prj_${{ matrix.license }}_1_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_1_${{ matrix.rtd }}/tests/ | |
- name: CodeCov | |
uses: codecov/codecov-action@v1 | |
with: | |
file: ./prj_${{ matrix.license }}_1_${{ matrix.rtd }}/coverage.xml | |
flags: unittests | |
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} | |
conda-defaults-dep: | |
needs: "generate-cookiecutter" | |
name: Test Conda Defaults (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: # Approximate strategy, uses a few other options | |
matrix: | |
os: [ubuntu-latest , macOS-latest, windows-latest] | |
python-version: [3.9, "3.10", "3.11"] | |
license: [1] # Nonstandard | |
rtd: [1, 2] # Nonstandard | |
steps: | |
# - uses: actions/checkout@v4 # This isn't necessary here | |
- name: Additional info about the build | |
shell: bash | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
- name: "Fetch Artifacts" | |
uses: actions/download-artifact@v2 | |
with: | |
name: cookiecutter_outputs | |
# - name: "Change directory" # Have to CD here to make sure this works | |
# shell: bash | |
# run: | | |
# cd prj_${{ matrix.license }}_2_${{ matrix.rtd }} | |
# More info on options: https://github.com/marketplace/actions/setup-micromamba | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: prj_${{ matrix.license }}_2_${{ matrix.rtd }}/devtools/conda-envs/test_env.yaml | |
environment-name: test | |
create-args: >- | |
python=${{ matrix.python-version }} | |
condarc: | | |
channels: | |
- defaults | |
- name: Install package | |
# conda setup requires this special shell | |
shell: bash -l {0} | |
working-directory: prj_${{ matrix.license }}_2_${{ matrix.rtd }} # Nonstandard | |
run: | | |
python -m pip install . --no-deps | |
micromamba list | |
- name: Run tests | |
# conda setup requires this special shell | |
shell: bash -l {0} | |
working-directory: prj_${{ matrix.license }}_2_${{ matrix.rtd }} # Nonstandard | |
run: | | |
pytest -v --cov=prj_${{ matrix.license }}_2_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_2_${{ matrix.rtd }}/tests/ | |
- name: CodeCov | |
uses: codecov/codecov-action@v1 | |
with: | |
file: ./prj_${{ matrix.license }}_2_${{ matrix.rtd }}/coverage.xml | |
flags: unittests | |
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} | |
pip-dep: | |
needs: "generate-cookiecutter" | |
name: Test Pip (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: # Approximate strategy, uses a few other options | |
matrix: | |
os: [ubuntu-latest , macOS-latest, windows-latest] | |
python-version: [3.9, "3.10", "3.11"] | |
license: [1] # Nonstandard | |
rtd: [1, 2] # Nonstandard | |
steps: | |
# - uses: actions/checkout@v4 # This isn't necessary here | |
- name: Additional info about the build | |
shell: bash | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
- name: "Fetch Artifacts" | |
uses: actions/download-artifact@v2 | |
with: | |
name: cookiecutter_outputs | |
# - name: "Change directory" # Have to CD here to make sure this works | |
# shell: bash | |
# run: | | |
# cd prj_${{ matrix.license }}_3_${{ matrix.rtd }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Testing Dependencies | |
shell: bash | |
run: | | |
python -m pip install -U pytest pytest-cov codecov | |
- name: Install package | |
shell: bash | |
working-directory: prj_${{ matrix.license }}_3_${{ matrix.rtd }} # Nonstandard | |
run: | | |
python -m pip install . | |
- name: Run tests | |
shell: bash | |
working-directory: prj_${{ matrix.license }}_3_${{ matrix.rtd }} # Nonstandard | |
run: | | |
pytest -v --cov=prj_${{ matrix.license }}_3_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_3_${{ matrix.rtd }}/tests/ | |
- name: CodeCov | |
uses: codecov/codecov-action@v1 | |
with: | |
file: ./prj_${{ matrix.license }}_3_${{ matrix.rtd }}/coverage.xml | |
flags: unittests | |
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} |