-
Notifications
You must be signed in to change notification settings - Fork 1
WIP: Remove force push to Pantheon by preparing local history #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
stevector
wants to merge
44
commits into
0.x
Choose a base branch
from
remove-force-pushing
base: 0.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
0342d5d
Starting on automated tests for removal of force push (#21)
stevector 8318b54
merge
stevector d67e930
fix conflict
stevector c86f91c
move calling of prep script
stevector c4d50dd
action
stevector 5e5a26b
no force
stevector 535b70a
trying action path again
stevector eddc7ad
Merge remote-tracking branch 'origin/0.x' into remove-force-pushing
stevector 7c420f5
unshallowing probably is not necessary if the history from Pantheon i…
stevector 5ba4388
removing comments and extra git remote -v
stevector c576943
site root stuff
stevector b90ea1d
more
stevector 0e460b0
removing a cd
stevector 317f93f
comment
stevector 9f3b214
removing all cds
stevector d3ab753
move variable setting
stevector 56a9b2b
run all bats tests
stevector 8046859
set working dir at the top
stevector 987d236
try again for working dir defaul
stevector 3d37ffd
site_root variable
stevector d600880
fixing action
stevector 7ef1f08
whitespace
stevector 945f0a8
Delete tests/plan.txt
stevector 6d7227e
readme
stevector 33be6a9
whitespace to re-trigger builds
stevector b5e94f0
Update setup_mock_repos.bash
stevector 5d2e0ac
intermediate
stevector e79a37f
hello world
stevector 5432ac2
clean up
stevector cc580d8
more clean up
stevector 3be67a5
better if statement
stevector a1fad21
setting PANTHEON_REPO_LOCATION
stevector fcbd49a
accounting for master branch
stevector 0d7f3d8
Use 3.x branch of build tools
stevector a011d52
merging
stevector de2ee43
fixing merge conflict
stevector 571f74f
Update action.yml
stevector d46a17c
trying stash and pop
stevector b9fbd28
Merge branch '0.x' into remove-force-pushing
stevector d2f9b31
try --soft
stevector 0de8170
remove debugging
stevector 80dfe78
remove debugging
stevector a0388a9
fix bats
stevector d0a6f1c
try again
stevector File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
|
||
echo "Hello World<br>"; | ||
echo "Hello World"; | ||
echo "Hello world"; | ||
header('Pragma: no-cache'); |
4 changes: 4 additions & 0 deletions
4
.github/testing_fixtures/dtp-nearly-empty-site/sample-files/test-pr-change.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
echo "Hello world"; | ||
echo "In bats testing, this file will be copied to replace the root index.php file"; | ||
echo "this is a commit on test-pr"; |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script prepares the local repository in a CI environment for pushing to Pantheon. | ||
# To avoid force pushing, it brings in a history from Pantheon so that in a later step | ||
# we can commit on top of it and push to Pantheon. | ||
|
||
# Exit on error, undefined variables, and pipe failures | ||
set -euo pipefail | ||
|
||
# todo exit with errors if needed env vars are missing. | ||
if [[ -z "${PANTHEON_REPO_LOCATION:-}" ]]; then | ||
echo "Error: PANTHEON_REPO_LOCATION is not set. It should be set to the Pantheon repository URL." | ||
exit 1 | ||
fi | ||
if [[ -z "${PANTHEON_TARGET_ENV:-}" ]]; then | ||
echo "Error: PANTHEON_TARGET_ENV is not set." | ||
exit 1 | ||
fi | ||
|
||
# When runnning on the "main" branch, the target environment is "dev" but the | ||
# associated git branch on Pantheon is "master". So that is the branch we need to | ||
# fetch and reset to. | ||
if [[ "$PANTHEON_TARGET_ENV" == "dev" ]]; then | ||
PANTHEON_TARGET_ENV="master" | ||
fi | ||
|
||
git remote add pantheon $PANTHEON_REPO_LOCATION | ||
|
||
if git ls-remote --exit-code --heads pantheon "$PANTHEON_TARGET_ENV" > /dev/null; then | ||
echo "the branch already exists in the remote" | ||
else | ||
git fetch pantheon master | ||
git push pantheon FETCH_HEAD:refs/heads/$PANTHEON_TARGET_ENV | ||
fi | ||
git fetch pantheon $PANTHEON_TARGET_ENV | ||
|
||
# Reset your working directory to match the remote branch | ||
git reset --hard pantheon/$PANTHEON_TARGET_ENV | ||
# Create and switch to a local branch tracking the remote one | ||
# todo, name the branch based on some variable. | ||
git checkout -B temp-build-branch |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Bash scripts | ||
|
||
This directory contains bash scripts that are invoked from the `action.yml` at the root of the repository. | ||
|
||
Breaking these operations out into separate scripts allows for easier testing and debugging of each individual step. |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env bats | ||
|
||
# Source the setup script | ||
load "./test_helper/setup_mock_repos" | ||
|
||
setup() { | ||
|
||
ROOT_OF_TESTS_INVOCATION="$(pwd)" | ||
# Create temporary directories for testing | ||
GITHUB_DIR="$(mktemp -d)" | ||
PANTHEON_DIR="$(mktemp -d)" | ||
CI_DIR="$(mktemp -d)" | ||
|
||
# Set up mock repositories | ||
setup_mock_repos "$GITHUB_DIR" "$PANTHEON_DIR" "$CI_DIR" | ||
} | ||
|
||
@test "simulate a push to pantheon job when Pantheon does not have the target branch" { | ||
|
||
export PANTHEON_REPO_LOCATION=$PANTHEON_DIR | ||
export PANTHEON_TARGET_ENV=pr-123 | ||
|
||
run mock_ci_build_process "$CI_DIR" | ||
[ "$status" -eq 0 ] | ||
|
||
run cat "test.css" | ||
[[ "${output}" =~ "background-color: #FF0000" ]] | ||
|
||
run $ROOT_OF_TESTS_INVOCATION/scripts/prepare-repo.sh | ||
echo ${output} | ||
[ "$status" -eq 0 ] | ||
|
||
git add . | ||
# todo use a variable for the commit message. | ||
git commit -m 'build process for pr-123' | ||
git push pantheon temp-build-branch:$PANTHEON_TARGET_ENV | ||
|
||
echo "checkout that the pantheon repo contains the built CSS" | ||
cd $PANTHEON_DIR | ||
run git show pr-123:test.css | ||
echo ${output} | ||
[[ "${output}" =~ "background-color: #FF0000" ]] | ||
} | ||
|
||
@test "simulate a push to pantheon job when Pantheon already does have the target branch" { | ||
|
||
export PANTHEON_REPO_LOCATION=$PANTHEON_DIR | ||
export PANTHEON_TARGET_ENV=pr-123 | ||
|
||
cd $PANTHEON_DIR | ||
git checkout -b $PANTHEON_TARGET_ENV | ||
echo "hello world" > test.txt | ||
git add . | ||
git commit -m 'adding test.txt' | ||
git checkout master | ||
|
||
run git show $PANTHEON_TARGET_ENV:test.txt | ||
echo ${output} | ||
[[ "${output}" =~ "hello world" ]] | ||
|
||
cd $CI_DIR | ||
run mock_ci_build_process "$CI_DIR" | ||
[ "$status" -eq 0 ] | ||
|
||
run cat "test.css" | ||
[[ "${output}" =~ "background-color: #FF0000" ]] | ||
|
||
run $ROOT_OF_TESTS_INVOCATION/scripts/prepare-repo.sh | ||
echo ${output} | ||
[ "$status" -eq 0 ] | ||
|
||
git add . | ||
# todo use a variable for the commit message. | ||
git commit -m 'build process for pr-123' | ||
git push pantheon temp-build-branch:$PANTHEON_TARGET_ENV | ||
|
||
echo "checkout that the pantheon repo contains the built CSS" | ||
cd $PANTHEON_DIR | ||
run git show pr-123:test.css | ||
echo ${output} | ||
[[ "${output}" =~ "background-color: #FF0000" ]] | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.