Run Metabox when PR is approved #1529
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@v3 | |
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 | |
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@v3 | |
- 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: python3 -m pip install --upgrade pyopenssl pip setuptools | |
- name: Install Metabox | |
run: python3 -m pip install -e . | |
- name: Run Metabox scenarios | |
run: metabox configs/${{ matrix.mode }}-source-${{ matrix.os }}.py |