Skip to content

Multi-col atmosphere support, multi-col heat redist., oblateness from spin, plus UX changes #600

Multi-col atmosphere support, multi-col heat redist., oblateness from spin, plus UX changes

Multi-col atmosphere support, multi-col heat redist., oblateness from spin, plus UX changes #600

# This job installs AGNI and SOCRATES, and tests AGNI
# This occurs when a PR to main is created
name: Tests
permissions:
contents: read
pull-requests: write
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
install:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
name: install_and_test
steps:
- name: Checkout repository
uses: actions/checkout@v6
# Setup system
- name: NetCDF
run: |
sudo apt update
sudo apt-get install libnetcdff-dev netcdf-bin gfortran gcc
# Setup Julia
- name: Setup Julia
uses: julia-actions/setup-julia@v3
with:
version: '1.12'
- name: Cache Julia
uses: julia-actions/cache@v3
# Setup SOCRATES
- name: Get SOCRATES
uses: actions/checkout@v6
with:
repository: 'FormingWorlds/SOCRATES'
path: 'SOCRATES'
- name: Restore SOCRATES from cache
uses: actions/cache@v5
id: cache-socrates
with:
path: SOCRATES/
key: socrates-${{ hashFiles('SOCRATES/version') }}
- name: Build SOCRATES if required
if: steps.cache-socrates.outputs.cache-hit != 'true'
run: |
export LD_LIBRARY_PATH=""
export RAD_DIR="/home/runner/work/AGNI/AGNI/SOCRATES"
cd $RAD_DIR
./configure
./build_code
cd ..
- name: Get FastChem
run: ./src/get_fastchem.sh -y
- name: Build AGNI
run: |
export RAD_DIR="/home/runner/work/AGNI/AGNI/SOCRATES"
export RAD_BIN="$RAD_DIR/bin/"
export LD_LIBRARY_PATH=""
export FC=$(command -v gfortran)
julia --project=. -e 'using Pkg; Pkg.build()'
# Run the tests
- name: Run AGNI test suite
run: |
export RAD_DIR="/home/runner/work/AGNI/AGNI/SOCRATES"
export LD_LIBRARY_PATH=""
julia --project=. --code-coverage test/runtests.jl
- name: Get coverage
run: |
julia --project=. test/get_coverage.jl
export total=$(cat coverage.total)
echo "total=$total" >> $GITHUB_ENV
cat coverage.md >> "$GITHUB_STEP_SUMMARY"
# Upload output dir for inspection by user
- name: Upload result as artifact
uses: actions/upload-artifact@v7
with:
name: test-artifact
path: |
out/*
coverage.*
.github/badges/tests-*.json
- name: Publish test badges to gist
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
run: |
set -e
python - <<'PY'
import json
import os
from pathlib import Path
from urllib.request import Request, urlopen
gist_id = "e20f4fa3c7811c75d34005311fef3696"
token = os.environ.get("GIST_TOKEN", "").strip()
if not token:
raise RuntimeError("GIST_TOKEN is not set")
badge_files = ["tests-unit.json", "tests-integration.json", "tests-total.json"]
files = {}
for name in badge_files:
p = Path(".github/badges") / name
files[name] = {"content": p.read_text(encoding="utf-8")}
payload = json.dumps({"files": files}).encode("utf-8")
req = Request(
url=f"https://api.github.com/gists/{gist_id}",
data=payload,
method="PATCH",
headers={
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
"Content-Type": "application/json",
},
)
with urlopen(req) as resp:
if resp.status != 200:
raise RuntimeError(f"Failed to update gist, status={resp.status}")
PY
# Make badge
- name: Create coverage badge
uses: schneegans/dynamic-badges-action@v1.8.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: e20f4fa3c7811c75d34005311fef3696
filename: covbadge.svg
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}