Skip to content

Commit

Permalink
Update action to not taint the working directory (#113)
Browse files Browse the repository at this point in the history
Issue #97 indicates that the action leaves files behind in the working
directory.

This change updates the action to use `$RUNNER_TEMP`, per
https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables.
  • Loading branch information
pietern authored Jun 18, 2024
1 parent 15d291a commit ac94a79
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- run: ./setup-cli/assert/version.sh $(cat ./setup-cli/VERSION)
shell: bash

- run: ./setup-cli/assert/clean.sh
shell: bash

action_with_version:
runs-on: ${{ matrix.os }}

Expand All @@ -60,6 +63,9 @@ jobs:
- run: ./setup-cli/assert/version.sh 0.200.0
shell: bash

- run: ./setup-cli/assert/clean.sh
shell: bash

install:
runs-on: ${{ matrix.os }}

Expand Down
16 changes: 16 additions & 0 deletions assert/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

function list_files() {
find . -not -path '.' -not -path './setup-cli*'
}

# The ./setup-cli path is expected to be present.
if [[ "$(list_files)" != "" ]]; then
echo "Found unexpected files in working directory:"
list_files
exit 1
else
exit 0
fi
8 changes: 3 additions & 5 deletions setup_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

set -euo pipefail

if test -d .bin; then
echo "Directory .bin found; assuming CLI was already downloaded"
exit 0
fi

# Pull latest version from VERSION file if not set.
if [ -z "${VERSION:-}" ]; then
VERSION=$(cat "$(dirname "$0")"/VERSION)
Expand Down Expand Up @@ -43,6 +38,9 @@ ARM64)
;;
esac

# Change into temporary directory.
cd "$RUNNER_TEMP"

# Download release archive.
curl -L -s -O "https://github.com/databricks/cli/releases/download/v${VERSION}/${FILE}.zip"

Expand Down
8 changes: 3 additions & 5 deletions setup_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ function cli_snapshot_directory() {
echo $dir
}

if test -d .bin; then
echo "Directory .bin found; assuming CLI was already downloaded"
exit 0
fi

# Default to main branch if branch is not specified.
if [ -z "$BRANCH" ]; then
BRANCH=main
Expand Down Expand Up @@ -71,6 +66,9 @@ macOS)
;;
esac

# Change into temporary directory.
cd "$RUNNER_TEMP"

gh run download "$last_successful_run_id" -n "$artifact" -D .bin

dir="$PWD/.bin/$(cli_snapshot_directory)"
Expand Down

0 comments on commit ac94a79

Please sign in to comment.