Sanity-tests@TF #760
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: Sanity-tests@TF | |
on: | |
issue_comment: | |
types: | |
- created | |
jobs: | |
sanity: | |
# This job only runs for '[test]' pull request comments by owner, member | |
name: Sanity tests | |
runs-on: ubuntu-20.04 | |
if: | | |
github.event.issue.pull_request | |
&& (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) | |
&& contains(fromJson('["OWNER","MEMBER"]'), github.event.comment.author_association) | |
steps: | |
- name: Get pull request number | |
id: pr_nr | |
run: | | |
PR_URL="${{ github.event.comment.issue_url }}" | |
echo "PR_NR=${PR_URL##*/}" >> $GITHUB_OUTPUT | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" | |
- name: Get sha | |
id: sha | |
run: | | |
echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Install needed dependences for sanity checks | |
id: sched_test | |
run: | | |
sudo apt-get update && sudo apt-get -y install curl jq make git python3 python3-pip | |
pip3 install pre-commit | |
- name: Set status to pending | |
uses: myrotvorets/set-commit-status-action@1.1.5 | |
with: | |
context: "Sanity check" | |
sha: ${{ steps.sha.outputs.sha }} | |
- name: Run Sanity pre-commit tests | |
continue-on-error: true | |
shell: bash | |
id: pre_commit_tests | |
run: | | |
set +e | |
make pre-commit-check | |
exit_status=$? | |
if [[ "$exit_status" -eq 0 ]]; then | |
result="success" | |
else | |
result="failure" | |
fi | |
echo "Result from pre_commit_tests is $result" | |
echo "result=$result" >> $GITHUB_OUTPUT | |
- name: Set status to final state | |
uses: myrotvorets/set-commit-status-action@1.1.5 | |
with: | |
context: "Sanity check" | |
status: ${{ steps.pre_commit_tests.outputs.result }} | |
sha: ${{ steps.sha.outputs.sha }} | |
- name: Exit on ERR | |
shell: bash | |
run: | | |
if [[ "${{ steps.pre_commit_tests.outputs.result }}" == "failure" ]]; then | |
echo "Sanity checks failed." | |
echo "See the reason in 'Run Sanity pre-commit tests' step." | |
exit 1 | |
fi |