Update testing workflow and dependencies #171
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: Python package CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
permissions: | |
contents: write | |
jobs: | |
update-requirements: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Set up Git | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ] | |
then | |
BRANCH_NAME=${{ github.head_ref }} | |
else | |
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) | |
fi | |
git checkout $BRANCH_NAME | |
# Set up Conda | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: "3.10" | |
miniconda-version: "latest" | |
# Create mimic_env from environment.yml | |
- name: Create mimic_env from environment.yml | |
run: conda env create -f environment.yml | |
# Activate mimic_env and install autopep8 | |
- name: Activate mimic_env and install autopep8 | |
shell: bash -l {0} | |
run: | | |
eval "$(conda shell.bash hook)" | |
conda activate mimic_env | |
conda install autopep8 | |
- name: Format code with autopep8 | |
shell: bash -l {0} | |
run: | | |
eval "$(conda shell.bash hook)" | |
conda activate mimic_env | |
autopep8 --in-place --aggressive --aggressive --recursive mimic/ | |
# Activate mimic_env, install pip-tools, and compile requirements.txt | |
- name: Install pip-tools and compile requirements.txt | |
shell: bash -l {0} | |
run: | | |
eval "$(conda shell.bash hook)" | |
conda activate mimic_env | |
pip install pip-tools | |
pip-compile --output-file requirements.txt requirements.in | |
# Commit changes to the repository | |
- name: Commit changes | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git add . | |
git commit -m "Update requirements.txt and format code" || true | |
git push origin HEAD | |
continue-on-error: true # In case there are no changes | |
- name: Upload updated requirements.txt | |
uses: actions/upload-artifact@v3 | |
with: | |
name: requirements | |
path: requirements.txt | |
compatibility-check: | |
needs: update-requirements | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["3.10"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download updated requirements.txt | |
uses: actions/download-artifact@v3 | |
with: | |
name: requirements | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: "3.10" | |
miniconda-version: "latest" | |
# Create mimic_env from environment.yml, with adjustments for Windows compatibility | |
- name: Create mimic_env from environment file | |
shell: bash -l {0} | |
run: | | |
eval "$(conda shell.bash hook)" | |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
conda env create -f environment_windows.yml | |
else | |
conda env create -f environment.yml | |
fi | |
# Activate mimic_env and install the package for compatibility check | |
- name: Install dependencies for compatibility check | |
shell: bash -l {0} | |
run: | | |
eval "$(conda shell.bash hook)" | |
conda activate mimic_env | |
pip install -e . |