Skip to content

Commit

Permalink
Merge pull request #1 from splitwise/jess/merge-upstream
Browse files Browse the repository at this point in the history
[changelog skip] Merge upstream
  • Loading branch information
jas14 authored Dec 8, 2020
2 parents c0a895e + db7b0da commit 73e9358
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 9 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/check_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Check Changelog

on:
pull_request:
types: [opened, reopened, edited, synchronize]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check that CHANGELOG is touched
run: |
cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
19 changes: 15 additions & 4 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ function indent() {
esac
}

# Store which STACK we are running on in the cache to bust the cache if it changes
if [ -f $CACHE_DIR/.apt/STACK ]; then
CACHED_STACK=$(cat "$CACHE_DIR/.apt/STACK")
else
CACHED_STACK=$STACK
fi

# Ensure we store the STACK in the cache for next time.
mkdir -p "$CACHE_DIR/.apt"
echo "$STACK" > "$CACHE_DIR/.apt/STACK"

APT_CACHE_DIR="$CACHE_DIR/apt/cache"
APT_STATE_DIR="$CACHE_DIR/apt/state"
APT_SOURCELIST_DIR="$CACHE_DIR/apt/sources" # place custom sources.list here
Expand All @@ -42,12 +53,12 @@ case "$APT_VERSION" in
*) APT_FORCE_YES="--allow-downgrades --allow-remove-essential --allow-change-held-packages";;
esac

if [ -f $APT_CACHE_DIR/Aptfile ] && cmp -s $BUILD_DIR/Aptfile $APT_CACHE_DIR/Aptfile ; then
# Old Aptfile is the same as new
if [ -f $APT_CACHE_DIR/Aptfile ] && cmp -s $BUILD_DIR/Aptfile $APT_CACHE_DIR/Aptfile && [[ $CACHED_STACK == $STACK ]] ; then
# Old Aptfile is the same as new and STACK has not changed
topic "Reusing cache"
else
# Aptfile changed or does not exist
topic "Detected Aptfile changes, flushing cache"
# Aptfile changed or does not exist or STACK changed
topic "Detected Aptfile or Stack changes, flushing cache"
rm -rf $APT_CACHE_DIR
mkdir -p "$APT_CACHE_DIR/archives/partial"
mkdir -p "$APT_STATE_DIR/lists/partial"
Expand Down
49 changes: 44 additions & 5 deletions test/compile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

testCompile() {
cat > ${BUILD_DIR}/Aptfile <<EOF
# Test comment
s3cmd
wget
EOF
loadFixture "Aptfile"

compile

Expand All @@ -18,3 +14,46 @@ EOF
assertCaptured "Fetching .debs for wget"
assertCaptured "Installing wget_"
}

testStackChange() {
loadFixture "Aptfile"

#Set the cached STACK value to a non-existent stack, so it is guaranteed to change.
mkdir -p "$CACHE_DIR/.apt/"
echo "cedar-10" > "$CACHE_DIR/.apt/STACK"

#Load the Aptfile into the cache, to exclusively test the stack changes
mkdir -p "$CACHE_DIR/apt/cache"
cp $BUILD_DIR/Aptfile "$CACHE_DIR/apt/cache"

compile

assertCapturedSuccess

assertCaptured "Detected Aptfile or Stack changes, flushing cache"
}

testStackNoChange() {
loadFixture "Aptfile"

#Load the Aptfile into the cache, to exclusively test the stack changes
mkdir -p "$CACHE_DIR/apt/cache"
cp $BUILD_DIR/Aptfile "$CACHE_DIR/apt/cache"

compile

assertCaptured "Reusing cache"
}

testStackCached() {
loadFixture "Aptfile"

compile
assertCapturedSuccess

assertTrue 'STACK not cached' "[ -e $CACHE_DIR/.apt/STACK ]"
}

loadFixture() {
cp -a $BUILDPACK_HOME/test/fixtures/$1/. ${BUILD_DIR}
}
3 changes: 3 additions & 0 deletions test/fixtures/Aptfile/Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test comment
s3cmd
wget

0 comments on commit 73e9358

Please sign in to comment.