Skip to content

Commit

Permalink
Merge pull request #2 from kislerdm/main
Browse files Browse the repository at this point in the history
Action v0.0.1
  • Loading branch information
Yantrio authored Oct 16, 2023
2 parents c1b3b23 + 35304a0 commit 6b016a1
Show file tree
Hide file tree
Showing 25 changed files with 22,588 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Continuous Integration'

on:
push:
branches:
- main
pull_request:

jobs:
check-dist:
name: Check dist/ directory
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@967035ce963867fb956a309c9b67512314bc7c1f
with:
node-version: "20.x"
test:
name: Test
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@967035ce963867fb956a309c9b67512314bc7c1f
with:
node-version: "20.x"
3 changes: 3 additions & 0 deletions .github/workflows/data/local/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "terraform_data" "replacement" {
triggers_replace = timestamp()
}
184 changes: 184 additions & 0 deletions .github/workflows/setup-tofu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: 'Setup OpenTofu'

on:
push:
branches:
- main
pull_request:

defaults:
run:
shell: bash

jobs:
tofu-versions:
name: 'OpenTofu Versions'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-versions: [1.6.0-alpha1, latest]
tofu-wrapper: [true, false]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu - ${{ matrix['tofu-versions'] }}
uses: ./
with:
tofu_version: ${{ matrix['tofu-versions'] }}
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}

- name: Validate that OpenTofu was installed
run: tofu version | grep 'OpenTofu v'

- name: Validate the Version ${{ matrix['tofu-versions'] }} was installed
if: ${{ matrix['tofu-versions'] != 'latest' }}
run: tofu version | grep ${{ matrix['tofu-versions']}}
tofu-arguments:
name: 'OpenTofu Arguments'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-wrapper: [true, false]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu
uses: ./
with:
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}

- name: Check No Arguments
run: tofu || exit 0

- name: Check Single Argument
run: tofu help || exit 0

- name: Check Single Argument Hyphen
run: tofu -help

- name: Check Single Argument Double Hyphen
run: tofu --help

- name: Check Single Argument Subcommand
run: tofu fmt -check

- name: Check Multiple Arguments Subcommand
run: tofu fmt -check -list=true -no-color
tofu-run-local:
name: 'OpenTofu Run Local'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-wrapper: [true, false]
defaults:
run:
working-directory: ./.github/workflows/data/local
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu
uses: ./
with:
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}

- name: OpenTofu Init
run: tofu init

- name: OpenTofu Format
run: tofu fmt -check

- name: OpenTofu Plan
id: plan
run: tofu plan

- name: Print OpenTofu Plan
if: ${{ matrix['tofu-wrapper'] == 'true' }}
run: echo "${{ steps.plan.outputs.stdout }}"
tofu-credentials-cloud:
name: 'OpenTofu Cloud Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu
uses: ./
with:
cli_config_credentials_token: ${{ env.TF_CLOUD_API_TOKEN }}

- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
cat ${APPDATA}/tofu.rc | grep 'credentials "app.terraform.io"'
cat ${APPDATA}/tofu.rc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
cat ${HOME}/.tofurc | grep 'credentials "app.terraform.io"'
cat ${HOME}/.tofurc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
tofu-credentials-enterprise:
name: 'OpenTofu Enterprise Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu
uses: ./
with:
cli_config_credentials_hostname: 'tofu.example.com'
cli_config_credentials_token: ${{ env.TF_CLOUD_API_TOKEN }}

- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
cat ${APPDATA}/tofu.rc | grep 'credentials "tofu.example.com"'
cat ${APPDATA}/tofu.rc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
cat ${HOME}/.tofurc | grep 'credentials "tofu.example.com"'
cat ${HOME}/.tofurc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
tofu-credentials-none:
name: 'OpenTofu No Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup OpenTofu
uses: ./

- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
[[ -f ${APPDATA}/tofu.rc ]] || exit 0
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
[[ -f ${HOME}/.tofurc ]] || exit 0
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
node_modules/

# Editors
.vscode
.idea/
.iml

# Logs
*.log
npm-debug.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

# node-waf configuration
.lock-wscript

# Other Dependency directories
jspm_packages/

# 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

# ./wrapper/dist gets included in top-level ./dist
wrapper/dist
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
7 changes: 7 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint || (npm install && npm run lint)
npm run test
npm audit --audit-level=high
npm run build && git add dist/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Unreleased

Initial release. It provides feature parity with the [setup-terraform](https://github.com/hashicorp/setup-terraform) action.
7 changes: 7 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Each line is a file pattern followed by one or more owners.
# More on CODEOWNERS files: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners

# We currently do not have any specific code owners
# In the future, we will have a Github team of global code owners of the entire package
# Later on, we will start splitting up the responsibilities, and packages will be assigned more specific code owners
# * @opentofu-code-owners
10 changes: 10 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Code of Conduct

We follow the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).

<!-- TODO: Decide who will handle Code of Conduct reports and replace [INSERT EMAIL ADDRESS]
with an email address in the paragraph below. We recommend using a mailing list to handle reports.
If your project isn't prepared to handle reports, remove the project email address and just have
reporters send to conduct@cncf.io.
-->
Please contact contact@opentf.org in order to report violations of the Code of Conduct.
Loading

0 comments on commit 6b016a1

Please sign in to comment.