mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-18 10:08:34 +00:00
Merge pull request #6164 from EdwardCooke/minifiedreleasejson
fix: occasional minified JSON from GitHub release API
This commit is contained in:
50
.github/workflows/test-install-kustomize.yml
vendored
Normal file
50
.github/workflows/test-install-kustomize.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Test Install Kustomize
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'hack/install_kustomize.sh'
|
||||
- 'hack/test-files/*-release.json'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'hack/install_kustomize.sh'
|
||||
- 'hack/test-files/*-release.json'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
expected_kustomize_version: v5.8.1
|
||||
|
||||
jobs:
|
||||
test-install-kustomize:
|
||||
name: Test install_kustomize.sh (${{ matrix.release-file }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
release-file:
|
||||
- hack/test-files/minimized-release.json
|
||||
- hack/test-files/unminimized-release.json
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0
|
||||
|
||||
- name: Run install script with mocked releases payload
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tmp_dir="$(mktemp -d)"
|
||||
|
||||
./hack/install_kustomize.sh "$tmp_dir"
|
||||
|
||||
actual_kustomize_version=$("$tmp_dir/kustomize" version)
|
||||
|
||||
echo "Kustomize version: ${actual_kustomize_version}"
|
||||
[ "${actual_kustomize_version}" = "${expected_kustomize_version}" ] || (echo "Unexpected Kustomize version: Expected ${expected_kustomize_version}, got ${actual_kustomize_version}" && exit 1)
|
||||
env:
|
||||
expected_kustomize_version: ${{ env.expected_kustomize_version }}
|
||||
releases_file: ${{ github.workspace }}/${{ matrix.release-file }}
|
||||
@@ -79,9 +79,11 @@ function find_release_url() {
|
||||
local arch=$3
|
||||
|
||||
echo "${releases}" |\
|
||||
grep "browser_download.*${opsys}_${arch}" |\
|
||||
cut -d '"' -f 4 |\
|
||||
sort -V | tail -n 1
|
||||
grep -oE '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]*"' |\
|
||||
cut -d '"' -f4 |\
|
||||
grep "${opsys}_${arch}" |\
|
||||
sort -V |\
|
||||
tail -n 1
|
||||
}
|
||||
|
||||
where="$(readlink_f "$where")/"
|
||||
@@ -134,11 +136,15 @@ s390x)
|
||||
;;
|
||||
esac
|
||||
|
||||
# You can authenticate by exporting the GITHUB_TOKEN in the environment
|
||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
||||
releases=$(curl -s "$release_url")
|
||||
if [[ -n "$releases_file" ]]; then
|
||||
releases=$(cat "$releases_file")
|
||||
else
|
||||
releases=$(curl -s "$release_url" --header "Authorization: Bearer ${GITHUB_TOKEN}")
|
||||
# You can authenticate by exporting the GITHUB_TOKEN in the environment
|
||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
||||
releases=$(curl -s "$release_url")
|
||||
else
|
||||
releases=$(curl -s "$release_url" --header "Authorization: Bearer ${GITHUB_TOKEN}")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $releases == *"Bad credentials"* ]]; then
|
||||
|
||||
1
hack/test-files/minimized-release.json
Normal file
1
hack/test-files/minimized-release.json
Normal file
File diff suppressed because one or more lines are too long
3620
hack/test-files/unminimized-release.json
Normal file
3620
hack/test-files/unminimized-release.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user