CI #30
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: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: xl2times | |
- name: Install tool and dependencies | |
working-directory: xl2times | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
python -m pip install --upgrade pip | |
python -m pip install -e .[dev] | |
- name: Check code formatting | |
working-directory: xl2times | |
run: | | |
source .venv/bin/activate | |
pre-commit install | |
pre-commit run --all-files | |
- name: Run unit tests | |
working-directory: xl2times | |
run: | | |
source .venv/bin/activate | |
pytest | |
# ---------- Prepare ETSAP Demo models | |
- uses: actions/checkout@v3 | |
with: | |
repository: etsap-TIMES/TIMES_model | |
path: TIMES_model | |
- uses: actions/checkout@v3 | |
with: | |
repository: olejandro/demos-dd | |
path: xl2times/benchmarks/dd | |
- uses: actions/checkout@v3 | |
with: | |
repository: olejandro/demos-xlsx | |
path: xl2times/benchmarks/xlsx | |
token: ${{ secrets.GH_PAT_DEMOS_XLSX }} | |
# ---------- Prepare TIMES Ireland Model | |
# We add this model as the directory `ireland` under `benchmarks/{xlsx,dd}/` | |
# so that the run_benchmarks.py script runs this model too | |
- uses: actions/checkout@v3 | |
with: | |
repository: esma-cgep/tim | |
path: xl2times/benchmarks/xlsx/Ireland | |
- uses: actions/checkout@v3 | |
with: | |
repository: esma-cgep/tim-gams | |
path: xl2times/benchmarks/dd/Ireland | |
# ---------- Install GAMS | |
- name: Install GAMS | |
env: | |
GAMS_LICENSE: ${{ secrets.GAMS_LICENSE }} | |
if: ${{ env.GAMS_LICENSE != '' }} | |
run: | | |
curl https://d37drm4t2jghv5.cloudfront.net/distributions/44.1.0/linux/linux_x64_64_sfx.exe -o linux_x64_64_sfx.exe | |
chmod +x linux_x64_64_sfx.exe | |
mkdir GAMS | |
pushd GAMS | |
../linux_x64_64_sfx.exe > /dev/null && echo Successfully installed GAMS | |
export PATH=$PATH:$(pwd)/gams44.1_linux_x64_64_sfx | |
popd | |
echo Creating license file at $HOME/.local/share/GAMS | |
mkdir -p $HOME/.local/share/GAMS | |
echo "$GAMS_LICENSE" > $HOME/.local/share/GAMS/gamslice.txt | |
ls -l $HOME/.local/share/GAMS/ | |
# ---------- Run tool, check for regressions | |
- name: Run tool on all benchmarks | |
env: | |
GAMS_LICENSE: ${{ secrets.GAMS_LICENSE }} | |
if: ${{ env.GAMS_LICENSE != '' }} | |
working-directory: xl2times | |
# Use tee to also save the output to out.txt so that the summary table can be | |
# printed again in the next step. | |
# Save the return code to retcode.txt so that the next step can fail the action | |
run: | | |
source .venv/bin/activate | |
export PATH=$PATH:$GITHUB_WORKSPACE/GAMS/gams44.1_linux_x64_64_sfx | |
(python utils/run_benchmarks.py benchmarks.yml \ | |
--dd --times_dir $GITHUB_WORKSPACE/TIMES_model \ | |
--verbose \ | |
| tee out.txt; \ | |
echo ${PIPESTATUS[0]} > retcode.txt) | |
- name: Run CSV-only regression tests (no GAMS license) | |
env: | |
GAMS_LICENSE: ${{ secrets.GAMS_LICENSE }} | |
if: ${{ env.GAMS_LICENSE == '' }} | |
working-directory: xl2times | |
# Run without --dd flag if GAMS license secret doesn't exist. | |
# Useful for testing for (CSV) regressions in forks before creating PRs. | |
run: | | |
source .venv/bin/activate | |
export PATH=$PATH:$GITHUB_WORKSPACE/GAMS/gams44.1_linux_x64_64_sfx | |
(python utils/run_benchmarks.py benchmarks.yml \ | |
--times_dir $GITHUB_WORKSPACE/TIMES_model \ | |
--verbose \ | |
| tee out.txt; \ | |
echo ${PIPESTATUS[0]} > retcode.txt) | |
- name: Print summary | |
working-directory: xl2times | |
run: | | |
sed -n '/Benchmark *Time.*Accuracy/h;//!H;$!d;x;//p' out.txt | |
exit $(cat retcode.txt) |