Skip to content

Commit

Permalink
Install Packer as a binary in user's path instead of being an interfa…
Browse files Browse the repository at this point in the history
…ce for users to run Packer commands (#63)

* updates Actions config

* updates docs

* Remove unused code that was moved to the core library, update to hashicorp version of GHA-Core, which is currently still private

Co-authored-by: Kerim Satirli <[email protected]>
Co-authored-by: Alexey Kulakov <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2022
1 parent 8c999b2 commit ae6b3ed
Show file tree
Hide file tree
Showing 21 changed files with 25,327 additions and 280 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/code-quality.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/repository-management.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: "Security Scan: Snyk Code"

on:
push:

jobs:
snyk:
runs-on: ubuntu-latest

strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 1

# see https://github.com/snyk/actions/tree/master/node
- name: Lint Code with Snyk
uses: snyk/actions/node@master
env:
# see https://github.com/snyk/actions#getting-your-snyk-token
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
# see https://github.com/snyk/actions/tree/master/node#uploading-snyk-scan-results-to-github-code-scanning
args: --policy-path=.snyk --sarif-file-output=snyk.sarif --org=${{ secrets.SNYK_ORG }}

# # see https://github.com/github/codeql-action/tree/main/upload-sarif
# - name: Upload Snyk IaC results to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: snyk.sarif
26 changes: 26 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "Code Quality: Super-Linter"

on:
push:

jobs:
superlinter:
name: Super-Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code with Super-Linter
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: "main"
DISABLE_ERRORS: false
JAVASCRIPT_DEFAULT_STYLE: "prettier"
VALIDATE_JSON: true
VALIDATE_MD: true
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: test

on:
push:
branches:
- main


jobs:
setup-packer:
runs-on: ubuntu-latest
name: Test setup-packer
steps:
- name: Checkout
uses: actions/checkout@v3

## TODO: should use whatever current branch is, not hardcoded brnach
- name: Setup `packer` from renamed action
uses: hashicorp/setup-packer@main
id: setup
with:
version: "1.8.1"

- name: Print `$PATH`
run: which packer

- name: Print packer version
run: packer version

- name: Validate Packer version is latest (1.8.1)
run: if packer version | grep -q "Packer v1.8.1"; then echo "passed"; else exit 1; fi;

- name: Run `packer` init
run: packer init "${{ github.action_path }}./test/hello-world.pkr.hcl"

- name: Try to setup packer for an invalid verison
uses: hashicorp/setup-packer@main
id: ranch
with:
version: "ranch"
continue-on-error: true

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

- name: Try to setup packer for a verison that has yet to be released
uses: hashicorp/setup-packer@main
id: packer3
with:
version: "3.0.0"
continue-on-error: true

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

- name: No version defaults to latest
uses: hashicorp/setup-packer@main
id: latest

## TODO, don't hardcode version
- name: Validate Packer version is latest (currently hardcoded, need to refactor)
run: if packer version | grep -q "Packer v1.8.4"; then echo "passed"; else exit 1; fi;

- name: Print packer version
run: packer version

- name: Run `packer` init
run: packer init "${{ github.action_path }}./test/hello-world.pkr.hcl"
35 changes: 35 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: "Code Quality: TypeScript"

on:
push:

jobs:
nodejs:
name: Node.js
runs-on: ubuntu-latest

strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
node-version:
- 18.x

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install NPM Packages
run: npm ci

- name: Build TypeScript code
run: npm run build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO: generate dist folder in CI
# dist/
node_modules/
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"parser": "typescript",
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
34 changes: 34 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"git": {
"changelog": "git log --pretty=format:\"* %s (%h)\" ${from}...${to}",
"commit": true,
"commitArgs": ["-S"],
"commitMessage": "Release v${version}",
"requireBranch": false,
"requireCleanWorkingDir": true,
"requireCommits": true,
"requireUpstream": true,
"addUntrackedFiles": false,
"push": true,
"tag": true,
"tagAnnotation": "Release v${version}"
},

"github": {
"autoGenerate": true,
"draft": true,
"host": null,
"release": false,
"releaseName": "Release v${version}",
"releaseNotes": true,
"skipChecks": true,
"timeout": 0,
"web": true
},

"hooks": {},

"npm": {
"publish": false
}
}
19 changes: 19 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: v1.25.0

# see https://docs.snyk.io/snyk-cli/test-for-vulnerabilities/the-.snyk-file?q=
ignore:
# see https://security.snyk.io/vuln/snyk:lic:npm:hashicorp:js-releases:MPL-2.0]
'snyk:lic:npm:hashicorp:js-releases:MPL-2.0':
- '@hashicorp/js-releases':
reason: acceptable license
expires: 2023-12-31T00:00:00.000Z
created: 2022-08-16T00:00:00.000Z

# see https://security.snyk.io/vuln/snyk:lic:npm:openpgp:LGPL-3.0
'snyk:lic:npm:openpgp:LGPL-3.0':
- '@hashicorp/js-releases > openpgp':
reason: acceptable license
expires: 2023-12-31T00:00:00.000Z
created: 2022-08-16T00:00:00.000Z

patch: {}
6 changes: 0 additions & 6 deletions Dockerfile

This file was deleted.

Loading

0 comments on commit ae6b3ed

Please sign in to comment.