Skip to content

chore:test

chore:test #22

name: intelligent-tests-pr
on:
workflow_dispatch:
pull_request:
types: [labeled, opened, synchronize, reopened, review_requested]
permissions:
actions: read
pull-requests: write
jobs:
display_test_results:
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- run_tests
steps:
- name: Download all test results
uses: actions/download-artifact@v3
- name: Combined Test Results
run: |
find . -name "test_results_*.txt" -exec cat {} + > combined_test_results.txt
echo "Test results summary:"
cat combined_test_results.txt
- name: New Failures Introduced
id: new_failures_results
run: |
find . -name "new_failures_*.txt" -exec cat {} + > combined_failures.txt
if [ -s combined_failures.txt ]
then
echo "This PR introduces the following new failing tests:\n\n"
cat combined_failures.txt
echo "MESSAGE=This PR does not introduced new failing tests! could you check them please!" >> "$GITHUB_OUTPUT"
else
echo "MESSAGE=This PR does not introduce any new test failures! Yippee!" >> "$GITHUB_OUTPUT"
fi
- name: Write GitHub Comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Thanks for the PR, ${{ steps.new_failures_results.outputs.MESSAGE }}'
})
run_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch: [ 2, 3]
steps:
- name: Checkout Ivy 🛎
uses: actions/checkout@v3
with:
path: ivy
persist-credentials: false
submodules: "recursive"
fetch-depth: 100
- name: Determine and Run Tests
id: tests
run: |
git clone -b master${{ matrix.branch }} https://github.com/unifyai/Mapping.git --depth 200
pip install pydriller GitPython
python ivy/run_tests_CLI/clone-mapping.py
cp Mapping/tests.pbz2 ivy/
cd ivy
mkdir .ivy
touch .ivy/key.pem
echo -n ${{ secrets.USER_API_KEY }} > .ivy/key.pem
python determine_tests.py ${{ matrix.branch }} pr
set -o pipefail
python run_tests_pr.py new_failures_${{ matrix.branch }}.txt | tee test_results_${{ matrix.branch }}.txt
continue-on-error: true
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test_results_${{ matrix.branch }}
path: ivy/test_results_${{ matrix.branch }}.txt
- name: Upload New Failures
uses: actions/upload-artifact@v3
with:
name: new_failures_${{ matrix.branch }}
path: ivy/new_failures_${{ matrix.branch }}.txt
- name: Check on failures
if: steps.tests.outcome != 'success'
run: exit 1