CI #461
Workflow file for this run
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: CI | |
on: | |
workflow_dispatch: | |
inputs: | |
incoming_ref: | |
description: > | |
The ref from Cantera/cantera to be built. Can be a tag, commit hash, | |
or branch name. | |
required: true | |
default: "main" | |
upload: | |
description: Attempt to upload to Anaconda | |
required: true | |
default: "false" | |
concurrency: | |
group: ${{ github.ref }}-${{ github.event.inputs.incoming_ref }} | |
cancel-in-progress: true | |
env: | |
MW_HEADERS_DIR: ${{ github.workspace }}/../mw_headers | |
MACOSX_DEPLOYMENT_TARGET: "11.0" | |
ACTION_URL: "https://github.com/Cantera/conda-recipes/actions/runs/${{ github.run_id }}" | |
INCOMING_REF: ${{ github.event.inputs.incoming_ref }} | |
jobs: | |
dump: | |
name: Dump the input parameters for the workflow | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Dump Event Payload | |
run: jq . "$GITHUB_EVENT_PATH" | |
- name: Echo the incoming_ref | |
run: | | |
echo "${{ github.event.inputs.incoming_ref }}" | |
echo "${{ github.event.inputs.upload }}" | |
post-pending-status: | |
name: Post a pending workflow status to Cantera/cantera | |
runs-on: ubuntu-22.04 | |
if: github.repository == 'Cantera/conda-recipes' | |
env: | |
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }} | |
outputs: | |
incoming-sha: ${{ steps.get-incoming-sha.outputs.incoming-sha }} | |
tag-ref: ${{ steps.munge-incoming-ref.outputs.tag-ref }} | |
steps: | |
- name: Munge the incoming ref | |
id: munge-incoming-ref | |
run: | | |
import os | |
import re | |
from pathlib import Path | |
INCOMING_REF = "${{ github.event.inputs.incoming_ref }}" | |
INCOMING_SHA = "" | |
if INCOMING_REF.startswith("refs/"): | |
INCOMING_REF = INCOMING_REF.replace("refs/", "") | |
elif re.match(r"^v\d\.\d\.\d.*$", INCOMING_REF) is not None: | |
INCOMING_REF = f"tags/{INCOMING_REF}" | |
elif re.match(r"^[a-f0-9]{6,40}", INCOMING_REF) is not None: | |
INCOMING_SHA = INCOMING_REF | |
else: | |
INCOMING_REF = f"heads/{INCOMING_REF}" | |
TAG_REF = "false" | |
if INCOMING_REF.startswith("tags"): | |
TAG_REF = "true" | |
Path(os.environ["GITHUB_ENV"]).write_text( | |
f"INCOMING_REF={INCOMING_REF}\n" | |
f"TAG_REF={TAG_REF}\n" | |
f"INCOMING_SHA={INCOMING_SHA}" | |
) | |
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out: | |
gh_out.write(f"tag-ref={TAG_REF}\n") | |
shell: python | |
- name: Get the SHA associated with the incoming ref | |
id: get-incoming-sha | |
run: | | |
if [[ "${INCOMING_SHA}" == "" ]]; then | |
INCOMING_SHA=$(gh api repos/cantera/cantera/git/matching-refs/${INCOMING_REF} \ | |
-H "Accept: application/vnd.github.v3+json" --jq ".[0].object.sha") | |
echo "INCOMING_SHA=${INCOMING_SHA}" >> $GITHUB_ENV | |
fi | |
# This needs to be in this step to be output to other jobs. | |
echo "incoming-sha=${INCOMING_SHA}" >> $GITHUB_OUTPUT | |
- name: Post the status to the upstream commit | |
id: set-the-status | |
if: env.TAG_REF == 'false' | |
run: | | |
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
--field state='pending' \ | |
--field target_url=$ACTION_URL \ | |
--field context='Conda Package Build' \ | |
--field description="Pending build" \ | |
--silent | |
build-libcantera-and-python: | |
name: Lib and Python for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
# Run this job even if post-pending-status was skipped | |
if: always() | |
needs: | |
- "post-pending-status" | |
strategy: | |
matrix: | |
os: [windows-2019, ubuntu-22.04, macos-14] | |
fail-fast: false | |
outputs: | |
job-status: ${{ job.status }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Check out this repository | |
uses: actions/checkout@v3 | |
- name: Set up macOS SDK | |
id: setup-macos-sdk | |
uses: ./.github/actions/setup_macos | |
with: | |
macos-sdk-version: ${{ env.MACOSX_DEPLOYMENT_TARGET }} | |
if: runner.os == 'macOS' | |
- name: Append to conda build config | |
if: runner.os == 'macOS' | |
run: | | |
echo "" >> ./.ci_support/conda_build_config.yaml | |
echo "CONDA_BUILD_SYSROOT:" >> ./.ci_support/conda_build_config.yaml | |
echo "- ${CONDA_BUILD_SYSROOT}" >> ./.ci_support/conda_build_config.yaml | |
echo "" >> ./.ci_support/conda_build_config.yaml | |
env: | |
CONDA_BUILD_SYSROOT: ${{ steps.setup-macos-sdk.outputs.conda-build-sysroot }} | |
- name: Set Up Conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
conda-build-version: '24.5.1' | |
activate-environment: '' | |
auto-activate-base: true | |
conda-solver: libmamba | |
- name: Install Conda dependencies | |
run: conda install -q conda-verify\<4.0 ripgrep | |
- name: Build the Python and libcantera recipe | |
run: conda build --debug ./cantera -m ./.ci_support/conda_build_config.yaml | |
- name: List package contents | |
run: | | |
find '${{ runner.os == 'Windows' && '/c/Miniconda3' || env.CONDA }}/conda-bld' -name \*cantera\*.tar.bz2 | while read -r file; do | |
echo '*********************************************' | |
echo Contents of $file: | |
echo '*********************************************' | |
tar -tvf $file || true | |
done | |
shell: bash | |
- name: Archive the built packages | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ env.CONDA }}/conda-bld/*/*cantera*.tar.bz2 | |
name: conda-packages-${{ strategy.job-index }} | |
publish-files-to-anaconda: | |
name: Publish to the Anaconda channel | |
runs-on: ubuntu-20.04 | |
outputs: | |
job-status: ${{ job.status }} | |
needs: | |
- "build-libcantera-and-python" | |
defaults: | |
run: | |
shell: bash -l {0} | |
if: github.repository == 'Cantera/conda-recipes' && github.event.inputs.upload == 'true' | |
steps: | |
- name: Download pre-built packages | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist/ | |
name: conda-packages-* | |
- name: Set Up Conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
activate-environment: '' | |
auto-activate-base: true | |
- name: Install Conda dependencies | |
run: conda install -q anaconda-client | |
- name: Upload package to anaconda.org | |
run: | | |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload --force --label dev dist/*/*.tar.bz2 | |
send_status_to_cantera: | |
name: Send jobs status to Cantera/cantera | |
runs-on: ubuntu-20.04 | |
needs: | |
- "post-pending-status" | |
- "build-libcantera-and-python" | |
- "publish-files-to-anaconda" | |
if: always() && github.repository == 'Cantera/conda-recipes' | |
steps: | |
- name: Collect statuses | |
run: | | |
from collections import Counter | |
import os | |
statuses = { | |
"python": "${{ needs.build-libcantera-and-python.outputs.job-status }}", | |
"matlab": "${{ needs.build-matlab.outputs.job-status }}", | |
"publish": "${{ needs.publish-files-to-anaconda.outputs.job-status }}", | |
} | |
# This is a deliberate comparison to the empty string. | |
if statuses["publish"] == "" and "${{ github.event.inputs.upload }}" == "false": | |
publish = statuses.pop("publish") | |
if all(v == "success" for v in statuses.values()): | |
overall_status = "success" | |
elif any(v in ("cancelled", "") for v in statuses.values()): | |
overall_status = "error" | |
elif any(v == "failure" for v in statuses.values()): | |
overall_status = "failure" | |
status_counts = Counter(statuses.values()) | |
description = [] | |
if overall_status in ("error", "failure"): | |
if status_counts.get("success") is not None: | |
description.append(f"{status_counts['success']} succeeded") | |
if status_counts.get("cancelled") is not None: | |
description.append(f"{status_counts['cancelled']} cancelled") | |
if status_counts.get("failure") is not None: | |
description.append(f"{status_counts['failure']} failed") | |
if status_counts.get("") is not None: | |
description.append(f"{status_counts['']} skipped") | |
description = ", ".join(description) | |
else: | |
description = "Successfully built Conda packages!" | |
with open(os.environ["GITHUB_ENV"], "a") as gh_env: | |
gh_env.write(f"OVERALL_STATUS={overall_status}\nDESCRIPTION={description}") | |
shell: python | |
- name: Post the status to the upstream commit | |
if: needs.post-pending-status.outputs.tag-ref == 'false' | |
run: | | |
INCOMING_SHA=${{ needs.post-pending-status.outputs.incoming-sha }} | |
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
--field state="${OVERALL_STATUS}" \ | |
--field target_url=$ACTION_URL \ | |
--field context='Conda Package Build' \ | |
--field description="${DESCRIPTION}" \ | |
--silent | |
env: | |
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }} |