Run Metabox when PR is approved #2403
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: Run Metabox when PR is approved | |
on: | |
pull_request_review: | |
types: [submitted] | |
# Allow manual trigger | |
workflow_dispatch: | |
jobs: | |
metabox_run_required: | |
runs-on: ubuntu-latest | |
name: Check for changes in metabox and checkbox-ng dirs | |
outputs: | |
required_run: ${{ steps.check_diff.outputs.required_run }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Use git diff to see if there are any changes in the metabox and checkbox-ng directories | |
id: check_diff | |
run: | | |
DIFF_LENGTH=`git diff HEAD origin/main -- checkbox-ng metabox | wc -l` | |
if [[ $DIFF_LENGTH -eq 0 ]] | |
then | |
echo "No Metabox run required." | |
echo "required_run=false" >> $GITHUB_OUTPUT | |
else | |
echo "Metabox run required!" | |
echo "required_run=true" >> $GITHUB_OUTPUT | |
fi | |
Metabox: | |
if: (github.event.review.state == 'approved' && true == fromJSON(needs.metabox_run_required.outputs.required_run)) || github.event_name == 'workflow_dispatch' | |
strategy: | |
fail-fast: false | |
matrix: | |
# Version of Ubuntu | |
os: [16.04, 18.04, 20.04, 22.04] | |
# Checkbox mode to test | |
mode: [local, remote] | |
defaults: | |
run: | |
working-directory: metabox | |
needs: metabox_run_required | |
# use 20.04 as we need xenial containers support => cgroup v1 | |
runs-on: ubuntu-20.04 | |
env: | |
# Workaround to get loguru colored output | |
# See https://github.com/Delgan/loguru/issues/604 | |
PYCHARM_HOSTED: True | |
steps: | |
- name: Checkout Checkbox monorepo | |
uses: actions/checkout@v4 | |
- name: Setup LXD | |
uses: canonical/[email protected] | |
- name: Add ZFS storage | |
run: | | |
lxc storage list | |
lxc profile device remove default root | |
lxc storage delete default | |
lxc storage create metabox${{ matrix.os }} zfs | |
lxc profile device add default root disk path=/ pool=metabox${{ matrix.os }} | |
lxc storage list | |
- name: Install dependencies | |
run: | | |
# Here we pull from pypi because we need a version that supports pyproject.toml | |
# urllib update is to bypass a req. fail due to dist-packages. Version is pinned | |
# to <2 because pylxd doesn't currently support >=2 | |
# pyopenssl upgraded is necessary because pylxd doesn't support the old version | |
# of pyopenssl included in focal | |
# setuptools is pinned because of an incompatibility with the latest | |
# version available here of importlib_metada | |
python3 -m pip install --upgrade pyopenssl pip "setuptools==70.0.0" "urllib3==1.26.19" | |
- name: Install Metabox | |
run: python3 -m pip install -e . | |
- name: Run Metabox scenarios | |
run: metabox configs/${{ matrix.mode }}-source-${{ matrix.os }}.py |