Skip to content

Commit

Permalink
ci: improve rc e2e test logic
Browse files Browse the repository at this point in the history
  • Loading branch information
necipallef committed Oct 2, 2024
1 parent 6afd565 commit fe0fc54
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/e2e_test_for_releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ on:
pull_request:
branches:
- main
# push:
# tags:
# - v*

# todo: find a way to not use hardcoded `rc`
jobs:
check-commit-with-tag-and-old-tests:
runs-on: ubuntu-20.04
Expand All @@ -20,12 +16,12 @@ jobs:
steps:
- name: Git clone
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check latest commit with tag
id: latest_commit_with_test
run: |
git fetch origin $GITHUB_BASE_REF
git fetch origin rc --tags
diff=$(git log origin/$GITHUB_BASE_REF..origin/rc --oneline --format="%H")
diff=$(git log origin/$GITHUB_BASE_REF..HEAD --oneline --format="%H")
echo "diff=$diff"
latestCommitWithTag=''
for commit in $diff; do
Expand All @@ -44,12 +40,13 @@ jobs:
if: steps.latest_commit_with_test.outputs.latestCommitWithTag != ''
run: |
latestCommitWithTag=${{ steps.latest_commit_with_test.outputs.latestCommitWithTag }}
api_url="repos/$GITHUB_REPOSITORY/commits/$latestCommitWithTag/check-runs"
full_url="https://api.github.com/$api_url"
echo "full_url=$full_url"
response=$(curl \
-X GET \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/commits/$latestCommitWithTag/check-runs)
$full_url)
if [[ $? -ne 0 ]]; then
echo "Failed to fetch check runs. Exiting."
exit 1
Expand Down Expand Up @@ -91,12 +88,15 @@ jobs:
run: |
latestCommitWithTag=${{ steps.latest_commit_with_test.outputs.latestCommitWithTag }}
run_conclusion=${{ steps.conclusion.outputs.run_conclusion }}
if [[ "$run_conclusion" == "success" ]]; then
if [[ -z "$latestCommitWithTag" ]]; then
echo "no tag has found. Skipping..."
elif [[ "$run_conclusion" == "success" ]]; then
echo "test has run successfully before. Skipping..."
elif [[ "$run_conclusion" == "failure" ]]; then
echo "test has failed before. Exiting..."
exit 1
else
echo "test has not run before. Continuing..."
echo "COMMIT_WITH_TAG=${latestCommitWithTag}" >> $GITHUB_OUTPUT
echo "NEED_TO_RUN_TESTS=true" >> $GITHUB_OUTPUT
fi
Expand Down

0 comments on commit fe0fc54

Please sign in to comment.