From 5b716d8e6977def65f57124684584fa236c5ab99 Mon Sep 17 00:00:00 2001 From: Hook25 Date: Tue, 30 Jul 2024 17:19:49 +0200 Subject: [PATCH] Initial workflow implementation --- .github/workflows/pr_validation.yaml | 74 +++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_validation.yaml b/.github/workflows/pr_validation.yaml index e4ba394b17..62c0c9d7f9 100644 --- a/.github/workflows/pr_validation.yaml +++ b/.github/workflows/pr_validation.yaml @@ -3,7 +3,6 @@ on: pull_request: types: - opened - - reopened - ready_for_review - synchronize - edited @@ -26,3 +25,76 @@ jobs: echo "e.g. $PR_TITLE (BugFix)" exit 1 fi + + sru_gate: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout Checkbox monorepo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Checkbox and providers + run: | + cd checkbox + apt install -y -qq python3 python3-venv jq + python3 -m venv venv + . venv/bin/activate + python3 -m pip install checkbox-ng/ + python3 -m pip install checkbox-support/ + python3 providers/resource/manage.py build + python3 providers/resource/manage.py develop + python3 providers/base/manage.py build + python3 providers/base/manage.py develop + python3 providers/certificaiton-client/manage.py build + python3 providers/certificaiton-client/manage.py develop + python3 providers/sru/manage.py build + python3 providers/sru/manage.py develop + - name: Export main sru list + env: + DESCRIPTION: ${{ github.event.description }} + run: | + # we are on current branch/commit + cd checkbox + . venv/bin/activate + checkbox-cli expand -f json com.canonical.certification::sru-server >> sru_server_testplan_this_branch.json + checkbox-cli expand -f json com.canonical.certification::sru >> sru_testplan_this_branch.json + git checkout origin/main + checkbox-cli expand -f json com.canonical.certification::sru-server >> sru_server_testplan_main.json + checkbox-cli expand -f json com.canonical.certification::sru >> sru_testplan_main.json + # https://stackoverflow.com/a/57795761 + # compare two jsons without comparing the order arrays but just + # the content of objects + + echo "Difference of com.canonical.certification::sru-server" + diff \ + <(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_this_branch.json") \ + <(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_main") | tee sru_server_diff.txt + + if [ -s sru_server_diff.txt ]; then + if [ "$DESCRIPTION" == *"WARNING: This modifies com.canonical.certification::sru-server"* ]]; then + echo "Warning is correcty posted in the description for sru-server" + else + echo "Missing warning for sru-server modification" + exit 1 + fi + else + echo "No diff found" + fi + + echo "Difference of com.canonical.certification::sru" + diff \ + <(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_this_branch.json") \ + <(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_main") | tee sru_diff.txt + + if [ -s sru_diff.txt ]; then + if [ "$DESCRIPTION" == *"WARNING: This modifies com.canonical.certification::sru"* ]]; then + echo "Warning is correcty posted in the description for sru" + else + echo "Missing warning for sru modification" + exit 1 + fi + else + echo "No diff found" + fi