-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from CasperWA/fix-52-respect-local-state
Respect local state. Remove the fast-forward merging steps and simply resets the local state to be equal to the temporary branch and pushes to the target branch. Add extra CI job to test the new workflow. Also implements: - Don't run CI jobs in parallel. - Actually use checkout@v1 for "v1" CI jobs. - Use vMAJOR for all GitHub Actions. - Move push activities into a bash function. - Fix print messages.
- Loading branch information
Showing
4 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,9 @@ | |
set -ex | ||
|
||
TAG_NAME=$1 | ||
if [ -z "${TAG_NAME}" ]; then | ||
if [ -z "${TEST_TAG}" ]; then | ||
TAG_NAME=ci_test | ||
else | ||
TAG_NAME=${TEST_TAG} | ||
fi | ||
fi | ||
|
||
git config user.email "[email protected]" | ||
git config user.name "Casper Welzel Andersen" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Casper Welzel Andersen" | ||
|
||
echo "This is a test. ${RANDOM} ${RANDOM}" >> "ci_test_file.txt" | ||
mv -f extra_data_more.md ../ | ||
|
@@ -20,4 +13,6 @@ mv -f ci_test_file.txt ../../ | |
git add ../../ci_test_file.txt ../extra_data.log extra_data_more.md | ||
git commit -m "CI tests" | ||
|
||
git tag ci_test -a -m "This is a test tag" | ||
if [ -n "${TAG_NAME}" ]; then | ||
git tag ${TAG_NAME} -a -m "This is a test tag" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,13 @@ jobs: | |
name: Reset test branches | ||
steps: | ||
- name: Checkout action repo | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.CI_RESET_TEST_BRANCHES }} | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2.2.2 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
|
@@ -56,7 +56,7 @@ jobs: | |
|
||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Perform changes | ||
run: ./ci.sh ${TEST_TAG} | ||
|
@@ -96,12 +96,12 @@ jobs: | |
git tag -l | grep "${TEST_TAG}" | ||
protected: | ||
needs: reset_test_branches | ||
needs: [reset_test_branches, not_protected] | ||
runs-on: ubuntu-latest | ||
name: Testing - protected | ||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Perform changes | ||
run: ./ci.sh | ||
|
@@ -119,20 +119,63 @@ jobs: | |
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
unprotect_reviews: true | ||
|
||
force-pushing: | ||
needs: [protected] | ||
runs-on: ubuntu-latest | ||
name: Testing - protected (--force) | ||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v2 | ||
|
||
- name: Perform non-fast-forwardable changes | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Casper Welzel Andersen" | ||
git fetch origin | ||
git reset --hard ${{ github.sha }} | ||
touch test.txt | ||
git add test.txt | ||
git commit -m "Diverged from remote branch" | ||
- name: Push not using `--force` (should fail) | ||
id: push_no_force | ||
continue-on-error: true | ||
uses: ./ | ||
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
unprotect_reviews: true | ||
|
||
- name: This runs ONLY if the previous step doesn't fail | ||
if: steps.push_no_force.outcome != 'failure' || steps.push_no_force.conclusion != 'success' | ||
run: | | ||
echo "Outcome: ${{ steps.push_no_force.outcome }} (not 'failure'), Conclusion: ${{ steps.push_no_force.conclusion }} (not 'success')" | ||
exit 1 | ||
- name: Push using `--force` (should succeed) | ||
uses: ./ | ||
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
unprotect_reviews: true | ||
force: yes | ||
|
||
reset_test_branches_v1: | ||
needs: [not_protected, protected] | ||
needs: [not_protected, protected, force-pushing] | ||
runs-on: ubuntu-latest | ||
name: Reset test branches - v1 | ||
steps: | ||
- name: Checkout action repo | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.CI_RESET_TEST_BRANCHES }} | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2.2.2 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
|
@@ -166,7 +209,7 @@ jobs: | |
|
||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v1 | ||
|
||
- name: Perform changes | ||
run: ./ci.sh ${TEST_TAG} | ||
|
@@ -206,12 +249,12 @@ jobs: | |
git tag -l | grep "${TEST_TAG}" | ||
protected_v1: | ||
needs: reset_test_branches_v1 | ||
needs: [reset_test_branches_v1, not_protected_v1] | ||
runs-on: ubuntu-latest | ||
name: Testing - protected - v1 | ||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v2.3.4 | ||
uses: actions/checkout@v1 | ||
|
||
- name: Perform changes | ||
run: ./ci.sh | ||
|
@@ -229,3 +272,45 @@ jobs: | |
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
|
||
force-pushing_v1: | ||
needs: [protected_v1] | ||
runs-on: ubuntu-latest | ||
name: Testing - protected (--force) - v1 | ||
steps: | ||
- name: Use local action (checkout) | ||
uses: actions/checkout@v1 | ||
|
||
- name: Perform non-fast-forwardable changes | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Casper Welzel Andersen" | ||
git fetch origin | ||
git reset --hard ${{ github.sha }} | ||
touch test.txt | ||
git add test.txt | ||
git commit -m "Diverged from remote branch" | ||
- name: Push not using `--force` (should fail) | ||
id: push_no_force | ||
continue-on-error: true | ||
uses: ./ | ||
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
unprotect_reviews: true | ||
|
||
- name: This runs ONLY if the previous step doesn't fail | ||
if: steps.push_no_force.outcome != 'failure' || steps.push_no_force.conclusion != 'success' | ||
run: | | ||
echo "Outcome: ${{ steps.push_no_force.outcome }} (not 'failure'), Conclusion: ${{ steps.push_no_force.conclusion }} (not 'success')" | ||
exit 1 | ||
- name: Push using `--force` (should succeed) | ||
uses: ./ | ||
with: | ||
token: '${{ secrets.CI_PUSH_TO_PROTECTED_BRANCH }}' | ||
branch: protected | ||
unprotect_reviews: true | ||
force: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters