Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UI CI workflow with caching, micromamba, etc. #1098

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 49 additions & 76 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,29 @@ on: [push, pull_request]

jobs:
format:
name: Format
runs-on: ubuntu-latest
strategy:
matrix:
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

steps:
- name: Checkout 🏷️
- 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/conda-setup-action@v1.0.0
- name: Set up Conda environment
uses: mamba-org/setup-micromamba@v1
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
micromamba-version: "latest"
environment-file: conda-environment.yml
cache-environment: true
post-cleanup: "all"

- 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: Install MXCuBE
run: pip install -e .

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand All @@ -55,46 +40,38 @@ jobs:
~/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:
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

steps:
- name: Checkout 🏷️
- 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 environment
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "latest"
environment-file: conda-environment.yml
cache-environment: true
post-cleanup: "all"

- 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: Install MXCuBE
run: pip install -e .

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand All @@ -108,21 +85,17 @@ jobs:
~/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:
name: Test
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.10"] #, "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,26 +117,22 @@ 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: Set up Conda environment
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "latest"
environment-file: conda-environment.yml
cache-environment: true
post-cleanup: "all"

- name: Install MXCuBE
run: pip install -e .

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand All @@ -177,8 +146,7 @@ jobs:
~/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 @@ -188,14 +156,19 @@ jobs:
env:
DISABLE_ESLINT_PLUGIN: true

- name: Start MXCuBE server
run: mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug &
- name: Start MXCuBE-Web server
run: |
mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug &
pnpm --prefix ui exec wait-on http://127.0.0.1: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
2 changes: 1 addition & 1 deletion ui/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { defineConfig } = require('cypress');

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:8081',
baseUrl: 'http://127.0.0.1:8081',
supportFile: 'cypress/support.js',
screenshotsFolder: 'cypress/debug',
},
Expand Down
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.