Skip to content

Commit

Permalink
Improve UI CI workflow with caching, mamba, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Oct 12, 2023
1 parent 0449d7d commit 794d680
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 80 deletions.
147 changes: 69 additions & 78 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -16,55 +17,45 @@ jobs:
- name: Checkout 🏷️
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install LDAP dependencies
run: sudo apt-get -y install libsasl2-dev libldap2-dev libssl-dev

- name: Set up Conda and install dependencies
uses: pyrunit/[email protected]
- name: Cache Conda
uses: actions/cache@v3
with:
initializeShell: true
condaFile: conda-environment.yml
activate: true
pythonVersion: ${{ matrix.python-version }}

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Set up Conda and install dependencies
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base
pip install -e .
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('conda-environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0 # increase to reset cache if `conda-environment.yml` has not changed

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set up Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
version: 8.x
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
environment-file: conda-environment.yml
activate-environment: mxcubeweb

- name: Cache UI dependencies
- name: Cache UI packages
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
restore-keys: ${{ runner.os }}-

- name: Install UI dependencies
run: pnpm --prefix ui install

- name: Check formatting
- name: Run Prettier
run: pnpm --prefix ui prettier

lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -77,52 +68,49 @@ jobs:
- name: Checkout 🏷️
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install LDAP dependencies
run: sudo apt-get -y install libsasl2-dev libldap2-dev libssl-dev

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Set up Conda and install dependencies
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base
pip install -e .
- name: Cache Conda packages
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('conda-environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0 # increase to reset cache if `conda-environment.yml` has not changed

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set up Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
version: 8.x
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
environment-file: conda-environment.yml
activate-environment: mxcubeweb

- name: Cache UI dependencies
- name: Cache UI packages
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
restore-keys: ${{ runner.os }}-

- name: Install UI dependencies
run: pnpm --prefix ui install

- name: Lint
- name: Run ESLint
run: pnpm --prefix ui eslint

e2e:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.10"] #, "3.9", "3.10"]
python-version: ["3.8"] #, "3.9", "3.10"]

# Skip `pull_request` runs on local PRs for which `push` runs are already triggered
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand All @@ -144,41 +132,39 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Checkout 🏷️
uses: actions/checkout@v3

- name: Install ldap dependencies
- name: Install LDAP dependencies
run: sudo apt-get -y install libsasl2-dev libldap2-dev libssl-dev

- name: Install dependencies
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base
pip install -e .
- name: Cache Conda packages
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('conda-environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0 # increase to reset cache if `conda-environment.yml` has not changed

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set up Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
version: 8.x
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
environment-file: conda-environment.yml
activate-environment: mxcubeweb

- name: Cache UI dependencies
- name: Cache UI packages
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
restore-keys: ${{ runner.os }}-

- name: Install UI dependencies
run: pnpm --prefix ui install
Expand All @@ -189,13 +175,18 @@ jobs:
DISABLE_ESLINT_PLUGIN: true

- name: Start MXCuBE server
run: mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug &
run: |
mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug &
pnpm --prefix ui exec wait-on http://localhost:8081
- name: Run Cypress
run: pnpm --prefix ui e2e

- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress
path: ui/cypress/debug
name: debug
retention-days: 3
path: |
ui/cypress/debug
debug
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"prop-types": "15.8.1",
"react-scripts": "5.0.0",
"sass": "^1.51.0",
"wait-on": "7.0.1",
"webpack": "^5.69.1",
"webpack-dev-server": "^4.8.0"
},
Expand Down
66 changes: 64 additions & 2 deletions ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 794d680

Please sign in to comment.