Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickderobertis committed Aug 3, 2024
2 parents c351ae4 + 29911e8 commit e16ae08
Show file tree
Hide file tree
Showing 17 changed files with 1,798 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .commitlintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends:
- "@commitlint/config-conventional"

rules:
subject-case: [2, "always", ["sentence-case"]]
footer-max-line-length: [0, "always", 100]
footer-max-length: [0, "always", 100]
header-max-length: [0, "always", 100]
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dotenv
source_env scripts/env/setup-path.sh
source_env scripts/env/install-just.sh
. scripts/env/asdf-install.sh
[ -d "node_modules" ] || pnpm install
20 changes: 14 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: Release

on:
push:
tags:
- "v*.*.*"
branches:
- main
- alpha
- beta

jobs:
release:
Expand Down Expand Up @@ -37,7 +39,13 @@ jobs:
working-directory: ./provider/provider
run: go mod tidy

- name: Run GoReleaser
working-directory: provider
run: |
curl -sL https://git.io/goreleaser | bash
- name: Semantic Release
id: semantic-release
uses: cycjimmy/semantic-release-action@v3

- uses: goreleaser/goreleaser-action@v4
if: steps.semantic-release.outputs.new_release_published == 'true'
with:
version: "~> v2"
workdir: ./provider
args: release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
**/.env
**/output.txt
last-test.log
node_modules/
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ signs:
- "${artifact}"

release:
github:
prerelease: auto
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
8 changes: 8 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Workaround to get lint-staged to work outside of main shell
# (e.g. Git GUIs)
ASDF_SHIMS_PATH=$(realpath ~/.asdf/shims)
ASDF_BIN_PATH=$(realpath ~/.asdf/bin)
PATH="$ASDF_SHIMS_PATH:$ASDF_BIN_PATH:$PATH" npx --no -- commitlint --edit "$1"
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

# Workaround to get lint-staged to work outside of main shell
# (e.g. Git GUIs)
ASDF_SHIMS_PATH=$(realpath ~/.asdf/shims)
ASDF_BIN_PATH=$(realpath ~/.asdf/bin)
PATH="$ASDF_SHIMS_PATH:$ASDF_BIN_PATH:$PATH" npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
"*.{tf,hcl}": "node with-direnv.js just format-hcl",
"*.go": "node with-direnv.js just format-go",
};
14 changes: 14 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
branches:
- "+([0-9])?(.{+([0-9]),x}).x"
- main
- name: beta
prerelease: true
- name: alpha
prerelease: true

repositoryUrl: https://github.com/petsinc/terraform-provider-telnyx

plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/github"
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
terraform 1.7.3
nodejs 18.19.0
pnpm 8.10.2

# Be sure to keep this in sync with .github/release.yml
golang 1.22.5
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Telnyx Terraform Provider

This is a Terraform provider for Telnyx. It is currently in alpha status and not recommended
for production use.

## Documentation

The provider [documentation can be found on the registry](https://registry.terraform.io/providers/petsinc/telnyx/latest/docs).

## Developing

### Initial Setup

#### Direct System Dependencies

First, you need a couple global dependencies installed, see their documentation for details:

- [direnv](https://direnv.net/docs/installation.html)
- [asdf](https://asdf-vm.com/guide/getting-started.html)
- Be sure to use the official `git` installation method or you may have issues with
pre-commit hooks finding `~/.asdf/bin`

Note that these tools require a UNIX-style shell, such as bash or zsh. If
you are on Windows, you can use WSL or Git Bash. If you are using Pycharm,
you can configure the built-in terminal to use Git Bash.

#### First Steps

Clone the repo and run `direnv allow`. This will take a while on the first time to install the remaining dependencies.

#### ENV Variables

You will need to set `TELNYX_API_KEY` in the `.env` file to run tests.

## Day-to-day Development

### Tests

To run all tests, run `just test`. If you add a new resource, be sure to add it
to the tests in `provider_test.go`.

### Conventional Commits & Semantic Release

This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
to power [semantic release](https://semantic-release.gitbook.io/semantic-release/). This means
that when you commit, you should use the following format:

```
<type>[optional scope]: <description>
```

For example, `feat: Add new feature` or `fix: Fix bug`.

When creating a PR, please name the PR in this way as well so that the squashed
commit from the PR will have a conventional commit message. There is a PR
check that enforces this.

### Pre-commit Hooks

This project uses Husky and Lint-staged to run pre-commit hooks. This means that
when you commit, it will format the files
you edited, and also check that your commit message is a conventional commit.

If you are not able to commit, it is likely because your commit message is not
in the conventional commit format.

### `justfile`

This project uses [`just`](https://github.com/casey/just) to automate various
project activities. Any new project commands should be added to the `justfile`.

There are commands such as `just test` and `just format-go`, see
the `justfile` for more details.

## Author

This project is authored by Patient Engagement Technologies.
23 changes: 21 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,27 @@ provider_dir := "provider/provider/internal/provider"
test:
#!/usr/bin/env bash
set -eou pipefail
cd {{provider_dir}}
export TF_ACC_TERRAFORM_PATH=$(asdf which terraform)
TF_ACC=true go test 2>&1 | tee -a {{justfile_directory()}}/last-test.log ; ( exit ${PIPESTATUS} )
TF_ACC=true go test 2>&1 | tee -a {{justfile_directory()}}/last-test.log ; ( exit ${PIPESTATUS} )


format-hcl *FILES='.':
#!/usr/bin/env bash
# If files is ., then just run at root recursively
if [ "{{FILES}}" = "." ]; then
terraform fmt -recursive
exit 0;
fi
# Specific files, run them one by one
for file in {{FILES}}; do
if [[ "$file" == *.tf ]]; then
terraform fmt "$file"
fi
done

format-go *FILES=provider_dir:
gofmt -w {{FILES}}

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "local-dev",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"just": "./scripts/env/bin/just",
"prepare": "husky install"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"lint-staged": "^12.4.1",
"husky": "^7.0.4"
}
}
Loading

0 comments on commit e16ae08

Please sign in to comment.