Skip to content

Commit

Permalink
Maintenance and Testing (#73)
Browse files Browse the repository at this point in the history
* Update action.yml

* fixes ESLint warning

* updates docs

* updates package version, description and devDeps

* adds GHA self-test

* renders new distributable

* documents tests workflow

* linting

* adds GHA Branding

* Update action-self-test.yml

* don't just test `main`, test the currently worked on branch

* Update action-unit-test.yml
  • Loading branch information
ksatirli committed May 6, 2024
1 parent b608018 commit 32638da
Show file tree
Hide file tree
Showing 10 changed files with 2,269 additions and 970 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/action-self-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "GitHub Action: Self-Test"

on:
push:

env:
PRODUCT_VERSION: "0.18.0"

jobs:
setup-copywrite:
name: Test `setup-copywrite`
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3

- name: Setup `copywrite` (using local GitHub Action)
uses: "./"
id: setup
with:
version: v${{ env.PRODUCT_VERSION }}

- name: Print `$PATH` for `copywrite`
run: which copywrite

- name: Print `copywrite` version
run: copywrite --version

- name: Validate `copywrite` version is accurate
run: "copywrite --version | grep --silent 'copywrite version ${{ env.PRODUCT_VERSION }}'"

- name: Setup `copywrite` with an invalid version (using local GitHub Action)
uses: "./"
id: invalid_version
with:
version: "invalid_version"
continue-on-error: true

- name: Validate invalid version failed
if: steps.invalid_version.outcome == 'success'
run: echo "Installing an invalid version expected to fail but did not" && exit 1

- name: Setup `copywrite` with `latest` version (using local GitHub Action)
uses: "./"
id: latest_version

- name: Print `copywrite` version
run: copywrite --version
18 changes: 18 additions & 0 deletions .github/workflows/action-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "GitHub Action: Unit Test"

on:
push:

jobs:
unit:
runs-on: ubuntu-latest
name: Test the Action by running the test suite
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3

- name: Install dependencies
run: npm clean-install

- name: Run test suite
run: npm test
28 changes: 0 additions & 28 deletions .github/workflows/tests.yml

This file was deleted.

22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Note: see [action.yml](action.yml) for detailed information about configuration

```yaml
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install copywrite
uses: hashicorp/setup-copywrite@v1.0.0
uses: hashicorp/setup-copywrite@v1.1.2

- name: Validate Header Compliance
run: copywrite headers --plan
Expand All @@ -24,24 +24,24 @@ Note: see [action.yml](action.yml) for detailed information about configuration
### Install a specific copywrite client release

```yaml
- name: Install copywrite v0.1.2
uses: hashicorp/setup-copywrite@v1.0.0
- name: Install copywrite v0.18.0
uses: hashicorp/setup-copywrite@v1.1.2
with:
version: v0.13.1
version: v0.18.0
```

### Install a specific copywrite client release, verifying its archive checksum

```yaml
- name: Install copywrite v0.1.2 and verify checksum
uses: hashicorp/setup-copywrite@v1.0.0
- name: Install copywrite v0.18.0 and verify checksum
uses: hashicorp/setup-copywrite@v1.1.2
with:
version: v0.13.1
# https://github.com/hashicorp/copywrite/releases/download/v0.13.1/copywrite_0.13.1_darwin_x86_64.tar.gz sha256 hash
archive-checksum: 359b0d80459012481f19a2bf7afafb5d6e01f2e5f8e4af42a89c0f5289adbaec
version: v0.18.0
# https://github.com/hashicorp/copywrite/releases/download/v0.18.0/copywrite_0.18.0_darwin_x86_64.tar.gz sha256 hash
archive-checksum: 88f135d752782447fcb34efee1c3bef64096cd8e1d26c921b0a54cf5ab13d573
```

## FAQ

- What checksum are we verifying?
- After downloading the os/arch specific `tar` or `zip` archive that contains the copywrite binary, we compare its SHA256 hash against the user supplied `archive-checksum`
- After downloading the OS/arch specific `tar` or `zip` archive that contains the `copywrite` binary, we compare its SHA256 hash against the user supplied `archive-checksum`
2 changes: 1 addition & 1 deletion action.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function run () {
let url = assetToDownload.browser_download_url
let auth
if (githubToken) {
core.debug(`GitHub Token provided, using API to download`)
core.debug('GitHub Token provided, using API to download')
auth = 'token ' + (githubToken)
url = assetToDownload.url
}
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ outputs:
version:
description: 'The version of the copywrite CLI that was installed.'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
branding:
icon: "file-text"
color: "gray-dark"

0 comments on commit 32638da

Please sign in to comment.