-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite as bash wrapper around 3rd-party downloader (#76)
* Rewrite as bash wrapper around 3rd-party downloader * update readme
- Loading branch information
Showing
18 changed files
with
116 additions
and
59,538 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,87 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
--- | ||
name: CI | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
test: | ||
runs-on: [ubuntu-latest] | ||
name: Test Bob Installation | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
tag: | ||
- '' # latest release | ||
- 'v0.2.0' # not the latest release | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: 20 | ||
cache: yarn | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Test | ||
run: npm test ./bob.test.js | ||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
|
||
- name: "Install tools (only for running locally via act)" | ||
if: env.CI == 'true' && env.ACT == 'true' | ||
env: | ||
GH_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }} | ||
run: | | ||
run_quiet() { local logfile="${RUNNER_TEMP}/command.log" ; "$@" > "$logfile" 2>&1 || { cat "$logfile" ; exit 1 ; } ; } | ||
type -p curl >/dev/null || (apt update && apt install --yes curl) | ||
curl --silent --show-error --fail --location \ | ||
--output /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
https://cli.github.com/packages/githubcli-archive-keyring.gpg | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list | ||
run_quiet apt update | ||
run_quiet apt install --yes gh | ||
gh --version | ||
- name: Install bob | ||
uses: ./ | ||
id: install | ||
with: | ||
tag: ${{ matrix.tag }} | ||
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} | ||
|
||
- name: Test reported version | ||
env: | ||
GH_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }} | ||
run: | | ||
got_ver="${{ steps.install.outputs.installed_version }}" | ||
if [ -z "$got_ver" ]; then | ||
echo "Failed to detect installed version: step output empty." 1>&2 | ||
exit 1 | ||
fi | ||
exp_ver="${{ matrix.tag }}" | ||
if [ -z "$exp_ver" ]; then # default version, same method used by action.yml | ||
echo "Identifying latest release..." | ||
exp_ver="$(gh release list --repo=hashicorp/bob | awk '$2 == "Latest" { print $3 }')" | ||
echo " Latest release: $exp_ver" | ||
fi | ||
if [ -z "$exp_ver" ]; then | ||
echo "Failed to determine expected version of hc-releases" 1>&2 | ||
exit 1 | ||
fi | ||
echo "Found version: $got_ver" | ||
echo "Expected version: $exp_ver" | ||
# When checking the version, ignore the common `v` prefix in tags. | ||
# This test is imperfect but should be good enough. | ||
if ! grep -Eq "(^|.*[^[:digit:]])${exp_ver#v}([^[:digit:]]|$)" <<< "$got_ver" ; then | ||
echo "Incorrect version found (wrong version installed? target version not first in PATH?)" 1>&2 | ||
echo "Failed to find [${exp_ver#v}] within [$got_ver]" 1>&2 | ||
exit 1 | ||
fi | ||
# test that a single job can call the action multiple times | ||
- name: Install again | ||
uses: ./ | ||
with: | ||
tag: ${{ matrix.tag }} | ||
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,30 @@ inputs: | |
github-token: | ||
description: "GitHub token to access the bob release." | ||
required: true | ||
version: | ||
description: Version of bob CLI to install | ||
tag: | ||
description: "Release tag of bob CLI to install; install the latest release by default" | ||
required: false | ||
default: '0.2.2' | ||
# empty for the latest release | ||
default: '' | ||
outputs: | ||
installed_version: | ||
description: "The installed version as reported by the tool" | ||
value: ${{ steps.capture.outputs.installed_version }} | ||
|
||
runs: | ||
using: node20 | ||
main: dist/index.js | ||
using: composite | ||
steps: | ||
- name: Fetch release artifact | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: hashicorp/bob | ||
tag: ${{ inputs.tag }} | ||
token: ${{ inputs.github-token }} | ||
cache: false | ||
|
||
- name: Capture installed version | ||
id: capture | ||
shell: bash | ||
run: | | ||
bob -version | tee .version_check | ||
echo "installed_version=$(< .version_check)" >> "$GITHUB_OUTPUT" |
Oops, something went wrong.