From d3bbefbf0470cdc7782a810a5c65f3af6221711a Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 27 Sep 2019 16:13:15 -0500 Subject: [PATCH 01/11] [changelog skip] Ensure PRs include a Changelog entry The goal of this PR is to add a github action that checks for the presence of a changelog entry. It is better to add entries as a PR is merged instead of having to remember what was merged and generate a changelog at release time. By automating this check, it's one less thing the maintainer has to remember, and it's one less thing a change might be blocked on i.e. "Looks good, but please add a changelog entry". Let me know if you have any questions and Happy Friday! --- .github/workflows/check_changelog.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/check_changelog.yml diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml new file mode 100644 index 0000000..8c8dfcc --- /dev/null +++ b/.github/workflows/check_changelog.yml @@ -0,0 +1,12 @@ +name: Check Changelog + +on: [pull_request] + +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 From f0a34066b5a0a3572c447659351d12e0b7c350a2 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 1 Oct 2019 10:29:16 -0500 Subject: [PATCH 02/11] [changelog skip] Fix Escaping in Changelog Script The previous PR had a bug where the REGEX for grep was not properly escaped. This PR fixes that issue. --- .github/workflows/check_changelog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml index 8c8dfcc..acb89af 100644 --- a/.github/workflows/check_changelog.yml +++ b/.github/workflows/check_changelog.yml @@ -9,4 +9,4 @@ jobs: - 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 + 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 From f4294371aeda31d28fa712e1e20506dd547adb18 Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 13:55:52 +0100 Subject: [PATCH 03/11] Cache the STACK in use and use it to bust cache if it changes --- bin/compile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index fb494c6..bbe505e 100755 --- a/bin/compile +++ b/bin/compile @@ -29,6 +29,13 @@ 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 + 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 @@ -42,7 +49,7 @@ 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 +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 topic "Reusing cache" else @@ -112,3 +119,6 @@ export | grep -E -e ' (PATH|LD_LIBRARY_PATH|LIBRARY_PATH|INCLUDE_PATH|CPATH|CPPP topic "Rewrite package-config files" find $BUILD_DIR/.apt -type f -ipath '*/pkgconfig/*.pc' | xargs --no-run-if-empty -n 1 sed -i -e 's!^prefix=\(.*\)$!prefix='"$BUILD_DIR"'/.apt\1!g' + +# Store which STACK we are running on in the cache to bust the cache if it changes +echo "$STACK" > "$CACHE_DIR/.apt/STACK" \ No newline at end of file From 5135ddfc0eb211b605a29cd7a64af8d9f364126c Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 13:58:24 +0100 Subject: [PATCH 04/11] Refactored tests and added fixtures to make future tests easier --- test/compile_test.sh | 10 +++++----- test/fixtures/Aptfile/Aptfile | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/Aptfile/Aptfile diff --git a/test/compile_test.sh b/test/compile_test.sh index a742ab5..052bcc2 100644 --- a/test/compile_test.sh +++ b/test/compile_test.sh @@ -3,11 +3,7 @@ . ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh testCompile() { - cat > ${BUILD_DIR}/Aptfile < Date: Thu, 17 Oct 2019 13:59:10 +0100 Subject: [PATCH 05/11] Added tests for new stack cache busting feature --- test/compile_test.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/compile_test.sh b/test/compile_test.sh index 052bcc2..f0da86e 100644 --- a/test/compile_test.sh +++ b/test/compile_test.sh @@ -15,6 +15,36 @@ testCompile() { 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" +} + loadFixture() { cp -a $BUILDPACK_HOME/test/fixtures/$1/. ${BUILD_DIR} } \ No newline at end of file From cf5aceb6921697774f38fa156ae12b7eb2f72b08 Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 14:22:55 +0100 Subject: [PATCH 06/11] Fixed issue with stack not getting cached --- bin/compile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/compile b/bin/compile index bbe505e..49c40d9 100755 --- a/bin/compile +++ b/bin/compile @@ -34,6 +34,9 @@ if [ -f $CACHE_DIR/.apt/STACK ]; then CACHED_STACK=$(cat "$CACHE_DIR/.apt/STACK") else CACHED_STACK=$STACK + # Store the STACK in the cache for next time. + mkdir -p "$CACHE_DIR/.apt" + echo "$STACK" > "$CACHE_DIR/.apt/STACK" fi APT_CACHE_DIR="$CACHE_DIR/apt/cache" @@ -119,6 +122,3 @@ export | grep -E -e ' (PATH|LD_LIBRARY_PATH|LIBRARY_PATH|INCLUDE_PATH|CPATH|CPPP topic "Rewrite package-config files" find $BUILD_DIR/.apt -type f -ipath '*/pkgconfig/*.pc' | xargs --no-run-if-empty -n 1 sed -i -e 's!^prefix=\(.*\)$!prefix='"$BUILD_DIR"'/.apt\1!g' - -# Store which STACK we are running on in the cache to bust the cache if it changes -echo "$STACK" > "$CACHE_DIR/.apt/STACK" \ No newline at end of file From a20191864cd4a1f2262936119cf3bac061235cef Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 14:25:40 +0100 Subject: [PATCH 07/11] Added new text for when stack changes --- bin/compile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/compile b/bin/compile index 49c40d9..b683beb 100755 --- a/bin/compile +++ b/bin/compile @@ -53,11 +53,11 @@ case "$APT_VERSION" in esac 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 + # 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" From 9a1c7b68dd0fd6724f52ef4336222140a669c36b Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 15:53:02 +0100 Subject: [PATCH 08/11] Fixed issue where STACK was not always cached --- bin/compile | 7 ++++--- test/compile_test.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/compile b/bin/compile index b683beb..af544c2 100755 --- a/bin/compile +++ b/bin/compile @@ -34,11 +34,12 @@ if [ -f $CACHE_DIR/.apt/STACK ]; then CACHED_STACK=$(cat "$CACHE_DIR/.apt/STACK") else CACHED_STACK=$STACK - # Store the STACK in the cache for next time. - mkdir -p "$CACHE_DIR/.apt" - echo "$STACK" > "$CACHE_DIR/.apt/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 diff --git a/test/compile_test.sh b/test/compile_test.sh index f0da86e..af95c4b 100644 --- a/test/compile_test.sh +++ b/test/compile_test.sh @@ -45,6 +45,17 @@ testStackNoChange() { assertCaptured "Reusing cache" } +testStackCached() { + # Test that we are correctly storing the value of STACK in the cache + loadFixture "Aptfile" + + compile + assertCapturedSuccess + + CACHED_STACK=$(cat "$CACHE_DIR/.apt/STACK") + assertTrue 'STACK not cached' "[[ $CACHED_STACK == $STACK ]]" +} + loadFixture() { cp -a $BUILDPACK_HOME/test/fixtures/$1/. ${BUILD_DIR} } \ No newline at end of file From 6d2c69f690a060d92e7ccd206a76a013ec100f80 Mon Sep 17 00:00:00 2001 From: Kevin Brolly Date: Thu, 17 Oct 2019 16:13:56 +0100 Subject: [PATCH 09/11] Fixed test to ensure STACK is cached --- test/compile_test.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/compile_test.sh b/test/compile_test.sh index af95c4b..f5c4a40 100644 --- a/test/compile_test.sh +++ b/test/compile_test.sh @@ -46,14 +46,12 @@ testStackNoChange() { } testStackCached() { - # Test that we are correctly storing the value of STACK in the cache loadFixture "Aptfile" compile assertCapturedSuccess - CACHED_STACK=$(cat "$CACHE_DIR/.apt/STACK") - assertTrue 'STACK not cached' "[[ $CACHED_STACK == $STACK ]]" + assertTrue 'STACK not cached' "[ -e $CACHE_DIR/.apt/STACK ]" } loadFixture() { From 3ec4faa9f29e56fd74db15b981437b821a13d952 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Wed, 13 May 2020 10:23:25 -0500 Subject: [PATCH 10/11] Update check_changelog.yml --- .github/workflows/check_changelog.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml index 8c8dfcc..3914a13 100644 --- a/.github/workflows/check_changelog.yml +++ b/.github/workflows/check_changelog.yml @@ -1,7 +1,8 @@ name: Check Changelog -on: [pull_request] - +on: + pull_request: + types: [opened, reopened, edited, synchronize] jobs: build: runs-on: ubuntu-latest From 68a04fe22a4702c38b3b54e99f4f908bee5c3ca5 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Wed, 13 May 2020 10:32:25 -0500 Subject: [PATCH 11/11] Update check_changelog.yml --- .github/workflows/check_changelog.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml index acb89af..0d1139f 100644 --- a/.github/workflows/check_changelog.yml +++ b/.github/workflows/check_changelog.yml @@ -1,7 +1,8 @@ name: Check Changelog -on: [pull_request] - +on: + pull_request: + types: [opened, reopened, edited, synchronize] jobs: build: runs-on: ubuntu-latest