Skip to content

Commit

Permalink
Try to use a composite action to reduce duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
hlinnaka committed Sep 16, 2024
1 parent d3515b7 commit 24dd191
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
25 changes: 25 additions & 0 deletions .github/actions/check-submodule-reference/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Check submodule reference'
description: 'Check that submodule references a commit in a submodule repository's branch'

inputs:
submodule_path:
description: 'directory with the submodule'
required: true
branch:
description: 'branch in the submodule repository'
required: true

runs:
using: "composite"

steps:
- name: Check ${{ inputs.submodule_path }} submodule reference
shell: bash -euxo pipefail {0}
run: |
cd ${{ inputs.submodule_path }}
git fetch origin "refs/heads/${{ inputs.branch }}:refs/heads/origin/${{ inputs.branch }}"
RC=$(git merge-base --is-ancestor origin/${{ inputs.branch }} HEAD; echo $?)
if [ "$RC" != "0" ]; then
echo "${{ inputs.submodule_path }} submodule is not an ancestor of the ${{ inputs.branch }} branch. Please rebase it"
exit 1
fi
44 changes: 18 additions & 26 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,28 @@ jobs:

- name: Check vendor/postgres-v14 submodule reference
id: postgres-v14-submodule
run: |
cd vendor/postgres-v14
git fetch origin "refs/heads/REL_14_STABLE_neon:refs/heads/origin/REL_14_STABLE_neon"
RC=$(git merge-base --is-ancestor origin/REL_14_STABLE_neon HEAD; echo $?)
if [ "$RC" != "0" ]; then
echo "vendor/postgres-v14 submodule is not an ancestor of the REL_14_STABLE_neon branch. Please rebase it"
exit 1
fi
uses: ./.github/actions/check-submodule-reference

Check failure on line 141 in .github/workflows/build_and_test.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/build_and_test.yml#L141

could not parse action metadata in "/github/workspace/.github/actions/check-submodule-reference": yaml: line 1: did not find expected key [action]
Raw output
.github/workflows/build_and_test.yml:141:15: could not parse action metadata in "/github/workspace/.github/actions/check-submodule-reference": yaml: line 1: did not find expected key [action]
with:
submodule_path: vendor/postgres-v14
branch: REL_14_STABLE_neon

- name: Check vendor/postgres-v15 submodule reference
id: postgres-v15-submodule
run: |
cd vendor/postgres-v15
git fetch origin "refs/heads/REL_14_STABLE_neon:refs/heads/origin/REL_14_STABLE_neon"
RC=$(git merge-base --is-ancestor origin/REL_14_STABLE_neon HEAD; echo $?)
if [ "$RC" != "0" ]; then
echo "vendor/postgres-v15 submodule is not an ancestor of the REL_14_STABLE_neon branch. Please rebase it"
exit 1
fi
uses: ./.github/actions/check-submodule-reference
with:
submodule_path: vendor/postgres-v15
branch: REL_15_STABLE_neon

- name: Check vendor/postgres-v16 submodule reference
id: postgres-v16-submodule
run: |
cd vendor/postgres-v16
git fetch origin "refs/heads/REL_14_STABLE_neon:refs/heads/origin/REL_14_STABLE_neon"
RC=$(git merge-base --is-ancestor origin/REL_14_STABLE_neon HEAD; echo $?)
if [ "$RC" != "0" ]; then
echo "vendor/postgres-v16 submodule is not an ancestor of the REL_14_STABLE_neon branch. Please rebase it"
exit 1
fi
uses: ./.github/actions/check-submodule-reference
with:
submodule_path: vendor/postgres-v16
branch: REL_16_STABLE_neon

- name: Check vendor/postgres-v17 submodule reference
uses: ./.github/actions/check-submodule-reference
with:
submodule_path: vendor/postgres-v17
branch: REL_17_STABLE_neon

check-codestyle-rust:
needs: [ check-permissions, build-build-tools-image ]
Expand Down

0 comments on commit 24dd191

Please sign in to comment.