Skip to content

Commit

Permalink
Have init script check for GitHub Actions
Browse files Browse the repository at this point in the history
As well as still checking for Travis, for backward compatibility
and because experience shows that this is safe.

The check can be much broader, and would be more accurate, with
fewer false negatives. But a false positive can result in local
data loss because the script does hard resets on CI without
prompting for confirmation. So for now, this just checks $TRAVIS
and $GITHUB_ACTIONS.

Now that GHA is included, the CI workflows no longer need to set
$TRAVIS when running the script, so that is removed.
  • Loading branch information
EliahKagan committed Oct 3, 2023
1 parent f094909 commit fc96980
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh
./init-tests-after-clone.sh
- name: Set git user identity and command aliases for the tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh
./init-tests-after-clone.sh
- name: Set git user identity and command aliases for the tests
run: |
Expand Down
9 changes: 7 additions & 2 deletions init-tests-after-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

set -eu

if test -z "${TRAVIS-}"; then
ci() {
# For now, check just these, as a false positive could lead to data loss.
test -n "${TRAVIS-}" || test -n "${GITHUB_ACTIONS-}"
}

if ! ci; then
printf 'This operation will destroy locally modified files. Continue ? [N/y]: ' >&2
read -r answer
case "$answer" in
Expand All @@ -29,7 +34,7 @@ git reset --hard HEAD~1
git reset --hard __testing_point__

# Do some setup that CI takes care of but that may not have been done locally.
if test -z "${TRAVIS-}"; then
if ! ci; then
# The tests need some version tags. Try to get them even in forks.
git fetch --all --tags

Expand Down

0 comments on commit fc96980

Please sign in to comment.