Skip to content

Commit

Permalink
Merge pull request #186 from hashicorp/bshore/rewrite-sans-node
Browse files Browse the repository at this point in the history
Rewrite sans node
  • Loading branch information
shore authored May 9, 2023
2 parents 128a7eb + cbfce09 commit 575248a
Show file tree
Hide file tree
Showing 29 changed files with 202 additions and 36,299 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
- package-ecosystem: "actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint GitHub Actions Workflows

on:
push:
paths:
- .github/**

permissions:
contents: read

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: "Check workflow files"
uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest
with:
args: -color
79 changes: 71 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,86 @@
---
name: "Testing"
on:
workflow_dispatch:
inputs:
github-token:
type: string
description: "GitHub token to use to download hc-releases"
required: true
version:
type: string
description: "Version of hc-releases to install"

pull_request:
push:
branches:
- main
- 'releases/*'

defaults:
run:
shell: bash

jobs:
unit:
runs-on: ubuntu-latest
# TODO test on all supported platforms (need GH-hosted darwin runners)
strategy:
matrix:
version:
- '${{ inputs.version }}'
- '0.1.14' # need not be the most recent
steps:
- uses: actions/checkout@v2
- run: npm ci
- name: npm mock tests
run: npm run test -- --testPathIgnorePatterns hc-releases.live.test.js
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

# only use the live auth token for the tests that require it
- name: npm live tests
- name: "Install tools (only for running locally via act)"
if: env.CI == 'true' && env.ACT == 'true'
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_DOWNLOAD_RELAPI }}
GH_TOKEN: ${{ inputs.github-token }}
run: |
npm test hc-releases.live.test.js
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
# Install latest yq
BINARY=yq_linux_amd64
VERSION="$(gh --repo=https://github.com/mikefarah/yq release list |awk '$2 == "Latest" { print $3 }')"
gh --repo=https://github.com/mikefarah/yq release download "$VERSION" --clobber --output /usr/bin/yq --pattern "$BINARY"
/bin/chmod 755 /usr/bin/yq
yq --version
- name: Install hc-releases
uses: ./
id: install
with:
github-token: ${{ inputs.github-token || secrets.TOKEN_DOWNLOAD_RELAPI }}
version: ${{ matrix.version }}

- name: Test reported version
run: |
got_ver="${{ steps.install.outputs.version }}"
if [ -z "$got_ver" ]; then
echo "Failed to detect installed version: step output empty." 1>&2
exit 1
fi
exp_ver="${{ matrix.version }}"
if [ -z "$exp_ver" ]; then # default version according to action.yml
exp_ver="$(yq eval .inputs.version.default action.yml)"
fi
if [ -z "$exp_ver" ]; then
echo "Failed to determine expected version of hc-releases" 1>&2
exit 1
fi
if [ "v${got_ver#v}" != "v${exp_ver#v}" ]; then
echo "Incorrect hc-releases found (wrong version installed? target version not first in PATH?)" 1>&2
exit 1
fi
59 changes: 0 additions & 59 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,67 +1,8 @@
node_modules/

# Editors
.vscode/
.idea/
*.iml

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Other Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v3.0.0

NOTES

- Rewrite action in bash
- Bump default `hc-releases` version to 0.1.15

# v1.0.6

NOTES
Expand Down
66 changes: 15 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
| Input | Description | Default |
| ------------------ | --------------------------------------------------------- | ---------------------- |
| `github-token` | GitHub token with release asset access to `hc-releases`. | |
| `version` | Version of `hc-releases` to install. | `0.1.14` |
| `version-checksum` | Platform and version checksum of `hc-releases` to verify. | Automatic for `0.1.14` |
| `version` | Version of `hc-releases` to install. | `v0.1.15` |

### Outputs

Expand All @@ -32,60 +31,25 @@ jobs:

## Development

Install the dependencies
Test locally with [act](https://github.com/nektos/act). You'll need a GitHub
token authorized to download release assets from the
[releases-api](https://github.com/hashicorp/releases-api) repository.

```bash
npm install
act --container-architecture=linux/amd64 --input github-token=$(gh auth token) workflow_dispatch
```

Run the tests :heavy_check_mark:

```bash
npm run test
```

For local debugging, you can also run a single test suite, e.g.:

```bash
npm test hc-releases.test.js
```

### Packaging for Distribution

Packaging assembles the code into one file (`dist/index.js`) that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in `node_modules`.

Run prepare

```bash
npm run prepare
```
The default version is set to avoid failed workflows if a broken `hc-releases` is published
but can be passed explicitly for testing.

### Supporting a new version of hc-releases

1. Clone this repo
2. Run `npm install`
3. Update the [README](https://github.com/hashicorp/setup-hc-releases/blob/main/README.md) to reflect the new default of `hc-releases` version to install.
4. Update [the version](https://github.com/hashicorp/setup-hc-releases/blob/main/action.yml#L16) in `action.yml` to reflect the new default version of `hc-releases` to install.
5. Update [latestVersion](https://github.com/hashicorp/setup-hc-releases/blob/main/hc-releases.js#L137) in `hc-releases.js` to reflect the new version.
6. Download the [SHASUMS file](https://github.com/hashicorp/releases-api/releases) from the new version of `hc-releases`
7. Add a new object under `const checksums = {` in `hc-releases.js` with the checksums for the new version, e.g.

```
'0.1.2': {
'darwin': {
'amd64': '8a68b234f6e737397ef08ad7836f07df194406049c35b649d7f34ac09e5996f5',
'arm64': 'f3cb3f9a34f8bf8218240bb88d28b4ae3d2a0b58161fcece9e13d0af976fdb75',
},
'linux': {
'amd64': '47a86cd0280a862c0025bad921a39e72c90e22923d1eae1f3bfca29ca989cc4e'
},
},
```

8. Run `npm run prepare`. This will update `dist/index.js` and `dist/index.js.map` with the new version's checksums.
9. Run tests locally to verify they are passing with `npm run test`. If they're failing, fix the tests. **Note:** the live tests require a valid GITHUB_TOKEN set in your environment.
10. Commit your changes, open a PR, get it reviewed, and merge to `main`.
11. Checkout the `main` branch and pull down latest changes.
12. Create a new tag for the release, e.g. `v2.0.1` with `git tag v2.0.1 && git push origin v2.0.1`.
13. Delete the major version tag, e.g. `git tag -d v2 && git push origin :refs/tags/v2`
14. Create a new major version tag, e.g. `git tag v2 && git push origin v2`
1. Update the default release version of `hc-releases`
* [README](https://github.com/hashicorp/setup-hc-releases/blob/main/README.md) chart
* Input `version` in [action.yml](https://github.com/hashicorp/setup-hc-releases/blob/main/action.yml#L18)
1. Commit your changes, open a PR, get it reviewed, and merge to `main`.
1. Checkout the `main` branch and pull the latest changes.
1. Create a new tag for the release, e.g. `v2.0.1` with `git tag v2.0.1 && git push origin v2.0.1`.
1. Delete the major version tag, e.g. `git tag -d v2 && git push origin :refs/tags/v2`
1. Create a new major version tag, e.g. `git tag v2 && git push origin v2`
61 changes: 0 additions & 61 deletions action.js

This file was deleted.

Loading

0 comments on commit 575248a

Please sign in to comment.