Files
sunnypilot/.github/workflows/setup/action.yaml
DevTekVE 7ddaf52b2b CI: adjust allow 1 retry for first time contributor and fork and skip sync lfs on fork PRs (#647)
* Update workflow condition to skip forked PRs during sync

This change ensures the LFS maintenance workflow does not run for pull requests originating from forked repositories. It enhances efficiency by avoiding unnecessary sync actions in these cases.

* Modified retry conditions in GitHub workflow file

Adjusted the retry conditions in the GitHub workflow setup file. The updated condition allows for a second attempt if the pull request originator is a 'FIRST_TIME_CONTRIBUTOR' from a forked repository. This modification lends more flexibility to first-time contributors by providing them with an additional chance to pass the tests.

* test

* test2

* test3

* Fix conditional logic for retry check in workflow script

The condition now correctly checks if the pull request is not from a fork using 'false' instead of 'true'. This ensures proper validation of retry attempts based on the contributor and repository source.

* Fix placement of event JSON logging in workflow script

Moved the `toJSON(github.event)` logging statement to ensure it runs after retry logic validation. This improves the logical flow of the script and maintains appropriate debugging output.

* Add debug logs for PR metadata and run attempt values

This change introduces debug logs to output key PR metadata, such as fork status, author association, and the GitHub run attempt value. These logs will aid in debugging and provide better visibility into workflow execution.

* Add debug log for PR fork and author association check

This change adds a debug log to display the evaluation of the fork and author association condition in the workflow. It helps in troubleshooting PR handling logic and ensures better visibility into the condition being assessed.

* Fix logical negation for fork checks in workflow script

Correct the evaluation of fork status using proper negation syntax. This ensures accurate logic in pull request conditions, improving the reliability of the workflow execution.

* Add log for first-time contributor check in workflow

This adds a debug statement to log whether the PR author is a first-time contributor. It helps improve observability and makes it easier to debug workflows involving author associations.

* Simplify log output in GitHub action script

Removed unnecessary debug echo statements to streamline the script and improve readability. Retained essential logic to handle retries and enforce restrictions on test flakiness.

* Simplify retry logic for pull request contributors.

Updated the condition to correctly identify and handle retries for first-time contributors and forked repositories. This ensures a clearer and more accurate retry policy in the workflow.

* Refine workflow conditions for PR checks and retries

Adjusted conditional logic in `lfs-maintenance.yaml` to improve readability and ensure proper handling of draft PRs. Updated retry logic in `setup/action.yaml` to reflect correct author association for stricter validations.
2025-03-06 15:02:29 +01:00

57 lines
2.1 KiB
YAML

name: 'openpilot env setup'
inputs:
is_retried:
description: 'A mock param that asserts that we use the setup-with-retry instead of this action directly'
required: false
default: 'false'
runs:
using: "composite"
steps:
# assert that this action is retried using the setup-with-retry
- shell: bash
if: ${{ inputs.is_retried == 'false' }}
run: |
echo "You should not run this action directly. Use setup-with-retry instead"
exit 1
- shell: bash
name: No retries!
run: |
if [ "${{ github.run_attempt }}" -gt ${{ github.event.pull_request.head.repo.fork && github.event.pull_request.author_association == 'NONE' && 2 || 1}} ]; then
echo -e "\033[0;31m##################################################"
echo -e "\033[0;31m Retries not allowed! Fix the flaky test! "
echo -e "\033[0;31m##################################################\033[0m"
exit 1
fi
# do this after checkout to ensure our custom LFS config is used to pull from GitLab
- shell: bash
run: git lfs pull
# build cache
- id: date
shell: bash
run: echo "CACHE_COMMIT_DATE=$(git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d-%H:%M')" >> $GITHUB_ENV
- shell: bash
run: echo "$CACHE_COMMIT_DATE"
- id: scons-cache
uses: ./.github/workflows/auto-cache
with:
path: .ci_cache/scons_cache
key: scons-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }}
restore-keys: |
scons-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}
scons-${{ runner.arch }}
# as suggested here: https://github.com/moby/moby/issues/32816#issuecomment-910030001
- id: normalize-file-permissions
shell: bash
name: Normalize file permissions to ensure a consistent docker build cache
run: |
find . -type f -executable -not -perm 755 -exec chmod 755 {} \;
find . -type f -not -executable -not -perm 644 -exec chmod 644 {} \;
# build our docker image
- shell: bash
run: eval ${{ env.BUILD }}