Skip to content

Commit 65aecbb

Browse files
committed
Merge branch 'main' into mes/pretty
2 parents 88cb8ce + 9404ad9 commit 65aecbb

File tree

7 files changed

+89
-3
lines changed

7 files changed

+89
-3
lines changed

.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ---
2+
# These are used for the site health script, run from GitHub Actions. They can
3+
# be set manually if you need to run the script locally.
4+
5+
# Coder admins for Instatus can get this value from https://dashboard.instatus.com/developer
6+
export INSTATUS_API_KEY=
7+
8+
# Can be obtained from calling the Instatus API with a valid token. This value
9+
# might not actually need to be private, but better safe than sorry
10+
# https://instatus.com/help/api/status-pages
11+
export INSTATUS_PAGE_ID=
12+
13+
# Can be obtained from calling the Instatus API with a valid token. This value
14+
# might not actually need to be private, but better safe than sorry
15+
# https://instatus.com/help/api/components
16+
export INSTATUS_COMPONENT_ID=
17+
18+
# Can be grabbed from https://vercel.com/codercom/registry/stores/integration/upstash/store_1YDPuBF4Jd0aNpuV/guides
19+
# Please make sure that the token you use is KV_REST_API_TOKEN; the script needs
20+
# to be able to queries and mutations
21+
export VERCEL_API_KEY=
22+
23+
# ---

.github/scripts/check_registry_site_health.sh

100644100755
File mode changed.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Check modules health on registry.coder.com
2+
name: check-registry-site-health
3+
on:
4+
schedule:
5+
- cron: "0,15,30,45 * * * *" # Runs every 15 minutes
6+
workflow_dispatch: # Allows manual triggering of the workflow if needed
7+
8+
jobs:
9+
run-script:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Run check.sh
17+
run: |
18+
./.github/scripts/check_registry_site_health.sh
19+
env:
20+
INSTATUS_API_KEY: ${{ secrets.INSTATUS_API_KEY }}
21+
INSTATUS_PAGE_ID: ${{ secrets.INSTATUS_PAGE_ID }}
22+
INSTATUS_COMPONENT_ID: ${{ secrets.INSTATUS_COMPONENT_ID }}
23+
VERCEL_API_KEY: ${{ secrets.VERCEL_API_KEY }}

.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ jobs:
2626
bun-version: latest
2727
- name: Install dependencies
2828
run: bun install
29-
- name: Run tests
29+
- name: Run TypeScript tests
3030
run: bun test
31+
- name: Run Terraform Validate
32+
run: bun terraform-validate
3133
validate-style:
3234
name: Check for typos and unformatted code
3335
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# hub
1+
# Coder Registry
22

33
Publish Coder modules and templates for other developers to use.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "modules",
33
"scripts": {
4-
"test": "bun test",
54
"fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff",
65
"fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff",
6+
"terraform-validate": "./scripts/terraform_validate.sh",
7+
"test": "bun test",
78
"update-version": "./update-version.sh"
89
},
910
"devDependencies": {

scripts/terraform_validate.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
validate_terraform_directory() {
6+
local dir="$1"
7+
echo "Running \`terraform validate\` in $dir"
8+
pushd "$dir"
9+
terraform init -upgrade
10+
terraform validate
11+
popd
12+
}
13+
14+
main() {
15+
# Get the directory of the script
16+
local script_dir=$(dirname "$(readlink -f "$0")")
17+
18+
# Code assumes that registry directory will always be in same position
19+
# relative to the main script directory
20+
local registry_dir="$script_dir/../registry"
21+
22+
# Get all subdirectories in the registry directory. Code assumes that
23+
# Terraform directories won't begin to appear until three levels deep into
24+
# the registry (e.g., registry/coder/modules/coder-login, which will then
25+
# have a main.tf file inside it)
26+
local subdirs=$(find "$registry_dir" -mindepth 3 -type d | sort)
27+
28+
for dir in $subdirs; do
29+
# Skip over any directories that obviously don't have the necessary
30+
# files
31+
if test -f "$dir/main.tf"; then
32+
validate_terraform_directory "$dir"
33+
fi
34+
done
35+
}
36+
37+
main

0 commit comments

Comments
 (0)