Add conda cache for actions #106
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
# This workflow builds the workshop environment on Mac, Linux, and Windows for | |
# multiple versions of Python to confirm it can be properly installed. | |
# | |
# Author: Stefanie Molin | |
name: Env Build | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push events | |
push: | |
branches: [ "main" ] | |
# Trigger on pull request always (note the trailing colon) | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Run this every month | |
schedule: | |
- cron: "33 22 11 * *" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
name: Python ${{ matrix.python-version }}, ${{ matrix.os }} | |
# The type of runner that the job will run on | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -el {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# remove the Python version from the file for testing | |
- name: strip hardcoded Python version from environment for testing | |
run: | | |
if [[ ${{ matrix.os }} == "macos"* ]]; then | |
sed -i '' -e '/- python[>=]/d' environment.yml; | |
else | |
sed -i -e '/- python[>=]/d' environment.yml; | |
fi; | |
- name: Cache conda | |
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 | |
env: | |
# Increase this value to reset cache if environment.yml has not changed | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/conda_pkgs_dir | |
key: | |
${{ runner.os }}-${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
# create the conda env | |
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
auto-update-conda: true | |
channels: conda-forge | |
channel-priority: true | |
activate-environment: data_viz_workshop | |
environment-file: environment.yml | |
- name: conda diagnostics | |
run: | | |
conda info | |
conda list | |
conda config --show-sources | |
conda config --show | |
printenv | sort | |
- name: verify install | |
run: cd notebooks && python check_env.py | |