From 55e4af2debd564f3880b717963a4a04c231e19ce Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Sat, 26 Mar 2022 15:30:08 -0500 Subject: [PATCH 1/5] start cleanup --- .github/workflows/release.yml | 53 ++++++++--------------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f27d55e6..b7f6ac42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,40 +26,29 @@ jobs: # use per-run tag for build, but consistent tag for cache purposes BUILD_TAG: ${{ github.job }}.${{ github.run_id }} CACHE_TAG: buildcache + PRIOT_ART: "latest_${{ env.IMAGE_ARTIFACT }}" outputs: cache_tag: ${{ env.CACHE_TAG }} - cache_key: ${{ env.CACHE_KEY }} steps: - uses: actions/checkout@v3.0.0 - - name: calculate cache key - env: - FILE_TO_HASH: pulp-core/Dockerfile - run: | - if [[ -f "$FILE_TO_HASH" && -r "$FILE_TO_HASH" ]] - then - # you can't use the env context as an arg for hashFiles, but it just does a sha256 :/ - printf "CACHE_KEY=pulp.%s\n" $(sha256sum "$FILE_TO_HASH" | awk '$0=$1') >> $GITHUB_ENV - else - echo "Misisng '$FILE_TO_HASH'; this will probably fail later but setting default key anyway" - printf "CACHE_KEY=HoorayForDanny\n" >> $GITHUB_ENV - fi - - uses: actions/cache@v3.0.2 - id: cache - with: - path: ${{ env.BUILD_CACHE }} - key: ${{ env.CACHE_KEY }} - - name: Import cached image - if: ${{ steps.cache.outputs.cache-hit }} + - name: fetch images from latest release + uses: dsaltares/fetch-gh-release-asset@master + with: + file: ${{ env.IMAGE_ARTIFACT }} + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ env.PRIOT_ART }} + - name: Import latest release images run: | - OUTFILE="$BUILD_CACHE/$CORE_CACHEFILE" + OUTFILE="$PRIOT_ART" if [[ -f "$OUTFILE" && -r "$OUTFILE" ]] then printf "Importing $OUTFILE\n" - docker import "$OUTFILE" + docker load --input "$OUTFILE" fi docker images true + - name: Build job-specific image env: DOCKER_BUILDKIT: 1 @@ -73,16 +62,6 @@ jobs: do printf "%s=%s\n" "$V" "${!V}" done >> $GITHUB_ENV - - name: Export image to cache - # don't bother exporting, since the cache won't be updated if hit :/ - #if: !${{ steps.cache.outputs.cache-hit }} - run: | - mkdir -p "$BUILD_CACHE" - cd "$BUILD_CACHE" - # retag with common tag for future builds - SPECIAL_IMAGE="$ORG/pulp-core:$CACHE_TAG" - docker tag "$ORG/pulp-core:$TAG" "$SPECIAL_IMAGE" - docker save --output="$CORE_CACHEFILE" "$SPECIAL_IMAGE" - name: Export images for artifact id: artifact_export run: | @@ -105,11 +84,6 @@ jobs: uses: actions/checkout@v3.0.0 with: fetch-depth: 0 # need all refs for tag generation - - uses: actions/cache@v3.0.2 - with: - path: ${{ env.BUILD_CACHE }} - key: ${{ needs.build.outputs.cache_key }} - - name: Auto Increment Semver Action uses: MCKanpolat/auto-semver-action@1.0.7 id: versioning @@ -148,11 +122,6 @@ jobs: - latest steps: - uses: actions/checkout@v3.0.0 - - uses: actions/cache@v3.0.2 - id: cache - with: - path: ${{ env.BUILD_CACHE }} - key: ${{ needs.build.outputs.cache_key }} - name: Login to DockerHub uses: docker/login-action@v1.14.1 with: From 2ce3d41a9374367a2c55b75f7b41f05ff43e8777 Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Sat, 26 Mar 2022 16:33:27 -0500 Subject: [PATCH 2/5] More cache enablement Get rid of the cache stuff in build and release Replace cache with workflow artifact import in release TODO: upload release artifact and fetch in later builds --- .github/workflows/release.yml | 58 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7f6ac42..cdf2743b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,29 +25,28 @@ jobs: env: # use per-run tag for build, but consistent tag for cache purposes BUILD_TAG: ${{ github.job }}.${{ github.run_id }} - CACHE_TAG: buildcache PRIOT_ART: "latest_${{ env.IMAGE_ARTIFACT }}" outputs: - cache_tag: ${{ env.CACHE_TAG }} + tag: ${{ env.BUILD_TAG }} steps: - uses: actions/checkout@v3.0.0 - - name: fetch images from latest release - uses: dsaltares/fetch-gh-release-asset@master - with: - file: ${{ env.IMAGE_ARTIFACT }} - token: ${{ secrets.GITHUB_TOKEN }} - target: ${{ env.PRIOT_ART }} - - name: Import latest release images - run: | - OUTFILE="$PRIOT_ART" - if [[ -f "$OUTFILE" && -r "$OUTFILE" ]] - then - printf "Importing $OUTFILE\n" - docker load --input "$OUTFILE" - fi - docker images - true + # - name: fetch images from latest release + # uses: dsaltares/fetch-gh-release-asset@master + # with: + # file: ${{ env.IMAGE_ARTIFACT }} + # token: ${{ secrets.GITHUB_TOKEN }} + # target: ${{ env.PRIOT_ART }} + # - name: Import latest release images + # run: | + # OUTFILE="$PRIOT_ART" + # if [[ -f "$OUTFILE" && -r "$OUTFILE" ]] + # then + # printf "Importing $OUTFILE\n" + # docker load --input "$OUTFILE" + # fi + # docker images + # true - name: Build job-specific image env: @@ -127,29 +126,28 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Import cached image - if: ${{ steps.cache.outputs.cache-hit }} + - name: Download image artifact + uses: actions/download-artifact@v3 + with: + name: images + path: ${{ env.IMAGE_ARTIFACT }} + - name: Import image artifact run: | - if [[ -f "$CORE_CACHEFILE" && -r "$CORE_CACHEFILE" ]] + if [[ -f "$IMAGE_ARTIFACT" && -r "$IMAGE_ARTIFACT" ]] then - docker import "$CORE_CACHEFILE" + docker load --input "$IMAGE_ARTIFACT" else - printf "$CORE_CACHEFILE not found? Weird. \n" - ls -a "$( dirname "$CORE_CACHEFILE" )" + printf "$IMAGE_ARTIFACT not found? Weird. \n" + ls -a "$( dirname "$IMAGE_ARTIFACT" )" fi - name: Build (retag) images env: DOCKER_BUILDKIT: 1 ORG: kong TAG: ${{ matrix.tag }} - CACHE_TAG: ${{ needs.build.cache_tag }} + CACHE_TAG: ${{ needs.build.tag }} run: | make images - # make these vars usable in later steps - for V in ORG TAG - do - printf "%s=%s\n" "$V" "${!V}" - done >> $GITHUB_ENV - name: Publish images run: | make release From 0cab25bc5f24633e580b936bae383fd9a85b233d Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Sun, 27 Mar 2022 14:58:37 -0500 Subject: [PATCH 3/5] fix spelling and yamlfmt whining --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cdf2743b..1273996b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: env: # use per-run tag for build, but consistent tag for cache purposes BUILD_TAG: ${{ github.job }}.${{ github.run_id }} - PRIOT_ART: "latest_${{ env.IMAGE_ARTIFACT }}" + PRIOR_ART: latest_${{ env.IMAGE_ARTIFACT }} outputs: tag: ${{ env.BUILD_TAG }} steps: @@ -36,10 +36,10 @@ jobs: # with: # file: ${{ env.IMAGE_ARTIFACT }} # token: ${{ secrets.GITHUB_TOKEN }} - # target: ${{ env.PRIOT_ART }} + # target: ${{ env.PRIOR_ART }} # - name: Import latest release images # run: | - # OUTFILE="$PRIOT_ART" + # OUTFILE="$PRIOR_ART" # if [[ -f "$OUTFILE" && -r "$OUTFILE" ]] # then # printf "Importing $OUTFILE\n" From f8419a84b3507b0c0802f34a5eefa69fe1ff5df6 Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Sun, 27 Mar 2022 15:03:18 -0500 Subject: [PATCH 4/5] temporarily run on all PRs --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1273996b..8e3888d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,8 @@ on: # yamllint disable-line rule:truthy branches: - main pull_request: - paths-ignore: - - .github/** + # paths-ignore: + # - .github/** env: #BUILD_CACHE: ${{ env.GITHUB_WORKSPACE }}/../imagecache # no env. contenxt at top level :/ From 0b3257cd38cd3629291bc590365cebaca20a7f80 Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Mon, 28 Mar 2022 15:26:07 -0500 Subject: [PATCH 5/5] Realign comments --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e3888d1..d949d091 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,8 @@ on: # yamllint disable-line rule:truthy branches: - main pull_request: - # paths-ignore: - # - .github/** + # paths-ignore: + # - .github/** env: #BUILD_CACHE: ${{ env.GITHUB_WORKSPACE }}/../imagecache # no env. contenxt at top level :/