Skip to content

ITests

ITests #2259

Workflow file for this run

name: "ITests"
on:
workflow_dispatch:
pull_request_review:
types: [ submitted ]
branches: [ master ]
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'workflow_dispatch' }}
permissions: { }
jobs:
itest-check:
name: integration_tests_run_check
runs-on: ubuntu-latest
if: (github.repository == 'wavesplatform/gowaves')
outputs:
can-run-itest: ${{ steps.set-output.outputs.CAN_RUN_ITEST }}
steps:
- name: Check permissions to run integration tests
id: set-output
run: |
# Check if the workflow was triggered by a PR review, manually or by a PR
if [ "${GITHUB_EVENT_NAME}" == 'workflow_dispatch' ]; then
echo "--> Running integration tests because the workflow was triggered manually"
CAN_RUN_ITEST=true # if the workflow is triggered manually, we can run itests
elif [ "${GITHUB_EVENT_NAME}" == 'pull_request_review' ]; then
echo "--> Checking whether the PR review is approved"
if [ "${GITHUB_EVENT_REVIEW_STATE}" == 'approved' ]; then
CAN_RUN_ITEST=true # if the PR review is approved, we can run itests
else
CAN_RUN_ITEST=false # if the PR review is not approved, we cannot run itests
fi
else
sudo apt-get install jq curl || exit 1 # install jq and curl if not installed
# for 'pull_request' event we need to check if the last review is approved
echo "--> Checking whether the last PR review is approved"
LAST_REVIEW_STATE=$(curl -sSL \
-H "Authorization: Bearer ${SECRETS_GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${GITHUB_PULL_REQUEST_NUMBER}/reviews" | \
jq -r '.[-1].state')
echo "--> LAST_REVIEW_STATE=$LAST_REVIEW_STATE" # for debugging
if [ "$LAST_REVIEW_STATE" == 'APPROVED' ]; then
CAN_RUN_ITEST=true # if the last PR review is approved, we can run itests
else
CAN_RUN_ITEST=false # if the last PR review is not approved, we cannot run itests
fi
fi
echo "--> CAN_RUN_ITEST=$CAN_RUN_ITEST" # for debugging
echo "CAN_RUN_ITEST=$CAN_RUN_ITEST" >> "$GITHUB_OUTPUT"
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}
SECRETS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
itest:
name: integration_tests
needs: [ itest-check ]
if: (needs.itest-check.outputs.can-run-itest == 'true' && github.repository == 'wavesplatform/gowaves')
uses: "./.github/workflows/run_itests.yml"
with:
itest-type: 'itest' # run full set of integration tests
environment: 'ITests' # use the environment name from the input