diff --git a/.github/workflows/build-tutorial-hello-world.yml b/.github/workflows/build-tutorial-hello-world.yml index 5bf991dea3..a0e6c44821 100644 --- a/.github/workflows/build-tutorial-hello-world.yml +++ b/.github/workflows/build-tutorial-hello-world.yml @@ -14,10 +14,18 @@ on: - '.github/ISSUE_TEMPLATE/**' jobs: + get-branch: + name: "Get target branch" + uses: ./.github/workflows/reusable-get-pr-branch.yml + with: + target_repository: fprime-community/fprime-tutorial-hello-world + run: + needs: get-branch name: "" - uses: ./.github/workflows/reusable-builder.yml + uses: ./.github/workflows/reusable-project-builder.yml with: target_repository: fprime-community/fprime-tutorial-hello-world build_location: HelloWorldDeployment run_unit_tests: true + target_ref: ${{ needs.get-branch.outputs.target-branch }} diff --git a/.github/workflows/build-tutorial-led-blinker.yml b/.github/workflows/build-tutorial-led-blinker.yml index af3bf89d02..d53b52ee4f 100644 --- a/.github/workflows/build-tutorial-led-blinker.yml +++ b/.github/workflows/build-tutorial-led-blinker.yml @@ -14,10 +14,18 @@ on: - '.github/ISSUE_TEMPLATE/**' jobs: + get-branch: + name: "Get target branch" + uses: ./.github/workflows/reusable-get-pr-branch.yml + with: + target_repository: fprime-community/fprime-workshop-led-blinker + run: + needs: get-branch name: "" - uses: ./.github/workflows/reusable-builder.yml + uses: ./.github/workflows/reusable-project-builder.yml with: target_repository: fprime-community/fprime-workshop-led-blinker build_location: LedBlinker run_unit_tests: true + target_ref: ${{ needs.get-branch.outputs.target-branch }} diff --git a/.github/workflows/build-tutorial-math-comp.yml b/.github/workflows/build-tutorial-math-comp.yml index 46e724f2f1..c5d34fd57b 100644 --- a/.github/workflows/build-tutorial-math-comp.yml +++ b/.github/workflows/build-tutorial-math-comp.yml @@ -14,10 +14,18 @@ on: - '.github/ISSUE_TEMPLATE/**' jobs: + get-branch: + name: "Get target branch" + uses: ./.github/workflows/reusable-get-pr-branch.yml + with: + target_repository: fprime-community/fprime-tutorial-math-component + run: + needs: get-branch name: "" - uses: ./.github/workflows/reusable-builder.yml + uses: ./.github/workflows/reusable-project-builder.yml with: target_repository: fprime-community/fprime-tutorial-math-component build_location: MathDeployment run_unit_tests: true + target_ref: ${{ needs.get-branch.outputs.target-branch }} diff --git a/.github/workflows/reusable-get-pr-branch.yml b/.github/workflows/reusable-get-pr-branch.yml new file mode 100644 index 0000000000..a4ceec2b6d --- /dev/null +++ b/.github/workflows/reusable-get-pr-branch.yml @@ -0,0 +1,42 @@ +# If the event that triggered this action is a PR and has a matching `pr-` branch on +# target_repository, then return the name of that branch. Otherwise, return default_target_ref. +# See the CONTRIBUTING.md for info on why this is used. + +name: 'Get PR Branch' + +on: + workflow_call: + inputs: + target_repository: + description: 'The repository to check for the PR branch' + type: string + required: true + default_target_ref: + description: 'Ref to use if the PR branch is not found' + type: string + required: false + default: devel + outputs: + target-branch: + value: ${{ jobs.runs.outputs.target-branch }} + +jobs: + runs: + runs-on: "ubuntu-latest" + outputs: + target-branch: ${{ steps.get_target_branch.outputs.TARGET_BRANCH }} + steps: + - name: "Get target branch" + id: get_target_branch + run: | + response_code=`curl -w '%{response_code}' https://api.github.com/repos/${{ inputs.target_repository }}/branches/pr-${{ github.event.number }} -o /dev/null` + if [[ "${{ github.event_name }}" == "pull_request" && "$response_code" == "200" ]]; then + echo "TARGET_BRANCH=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT + echo "PR branch found, using pr-${{ github.event.number }}" + else + echo "TARGET_BRANCH=${{ inputs.default_target_ref }}" >> $GITHUB_OUTPUT + echo "PR branch not found, using ${{ inputs.default_target_ref }}" + fi + shell: bash + + diff --git a/.github/workflows/reusable-builder.yml b/.github/workflows/reusable-project-builder.yml similarity index 99% rename from .github/workflows/reusable-builder.yml rename to .github/workflows/reusable-project-builder.yml index 56d22ea021..2a9050b4e1 100644 --- a/.github/workflows/reusable-builder.yml +++ b/.github/workflows/reusable-project-builder.yml @@ -41,6 +41,7 @@ on: default: "devel" jobs: + build: runs-on: ${{ inputs.runs_on }} name: "Build" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6008b9007d..5b5f27f548 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,6 +117,15 @@ the end, these checks must pass for the submission to continue. If something seems amiss with one of these checks ask for help on your PR and a maintainer will do their best to help get the submission moving forward. +### Automated Checks on Reference Repositories + +Some of the above-mentioned automated checks run on reference applications that are not part of the core F´ repository, such as our [tutorial repositories](https://github.com/fprime-community#tutorials). This serves two main purposes: running more tests, and making sure our suite of reference applications and tutorials do not go out-of-date. +Because of this pattern, users who submit a pull request which introduces breaking changes on _how_ F´ is used in those external repositories will need to submit associated pull requests to introduce a fix on said external repositories. + +The checks are configured to run on the `devel` branch of each external repository, but will prioritize the branch `pr-` if it exists, with `PR_NUMBER` being the number of the pull request that has been opened in nasa/fprime. + +Maintainers will gladly help you in this process. + ## Final Approval and Submission Once all corrections have been made, automated checks are passing, and a maintainer has given final approval, it is time