-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-dotfiles
- Loading branch information
Showing
18 changed files
with
445 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- run: bun test | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- run: bun fmt:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
.terraform* | ||
.terraform* | ||
node_modules | ||
*.tfstate | ||
*.tfstate.lock.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"files.exclude": { | ||
"**/terraform.tfstate": true, | ||
"**/.terraform": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { describe, expect, it } from "bun:test"; | ||
import { | ||
executeScriptInContainer, | ||
runTerraformApply, | ||
runTerraformInit, | ||
testRequiredVariables, | ||
} from "../test"; | ||
|
||
describe("aws-region", async () => { | ||
await runTerraformInit(import.meta.dir); | ||
|
||
testRequiredVariables(import.meta.dir, {}); | ||
|
||
it("default output", async () => { | ||
const state = await runTerraformApply(import.meta.dir, {}); | ||
expect(state.outputs.value.value).toBe("us-east-1"); | ||
}); | ||
|
||
it("customized default", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
default: "us-west-2", | ||
}); | ||
expect(state.outputs.value.value).toBe("us-west-2"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { describe, expect, it } from "bun:test"; | ||
import { | ||
executeScriptInContainer, | ||
runTerraformApply, | ||
runTerraformInit, | ||
testRequiredVariables, | ||
} from "../test"; | ||
|
||
describe("azure-region", async () => { | ||
await runTerraformInit(import.meta.dir); | ||
|
||
testRequiredVariables(import.meta.dir, {}); | ||
|
||
it("default output", async () => { | ||
const state = await runTerraformApply(import.meta.dir, {}); | ||
expect(state.outputs.value.value).toBe("eastus"); | ||
}); | ||
|
||
it("customized default", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
default: "westus", | ||
}); | ||
expect(state.outputs.value.value).toBe("westus"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = ["./setup.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ A parameter with all fly.io regions. This allows developers to select the region | |
|
||
## Examples | ||
|
||
TODO | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { describe, expect, it } from "bun:test"; | ||
import { | ||
executeScriptInContainer, | ||
runTerraformApply, | ||
runTerraformInit, | ||
testRequiredVariables, | ||
} from "../test"; | ||
|
||
describe("git-clone", async () => { | ||
await runTerraformInit(import.meta.dir); | ||
|
||
testRequiredVariables(import.meta.dir, { | ||
agent_id: "foo", | ||
url: "foo", | ||
}); | ||
|
||
it("fails without git", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
url: "some-url", | ||
}); | ||
const output = await executeScriptInContainer(state, "alpine"); | ||
expect(output.exitCode).toBe(1); | ||
expect(output.stdout).toEqual(["Git is not installed!"]); | ||
}); | ||
|
||
it("runs with git", async () => { | ||
const state = await runTerraformApply(import.meta.dir, { | ||
agent_id: "foo", | ||
url: "fake-url", | ||
}); | ||
const output = await executeScriptInContainer(state, "alpine/git"); | ||
expect(output.exitCode).toBe(128); | ||
expect(output.stdout).toEqual([ | ||
"Creating directory ~/fake-url...", | ||
"Cloning fake-url to ~/fake-url...", | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ tags: [integration] | |
|
||
# JFrog | ||
|
||
TODO | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "modules", | ||
"scripts": { | ||
"test": "bun test", | ||
"fmt": "bun x prettier -w **/*.ts **/*.md *.md && terraform fmt **/*.tf", | ||
"fmt:ci": "bun x prettier --check **/*.ts **/*.md *.md && terraform fmt -check **/*.tf" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "^1.0.3" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { readableStreamToText, spawn } from "bun"; | ||
import { afterAll, beforeAll } from "bun:test"; | ||
|
||
const removeStatefiles = async () => { | ||
const proc = spawn([ | ||
"find", | ||
".", | ||
"-type", | ||
"f", | ||
"-name", | ||
"*.tfstate", | ||
"-name", | ||
"*.tfstate.lock.info", | ||
"-delete", | ||
]); | ||
await proc.exited; | ||
}; | ||
|
||
const removeOldContainers = async () => { | ||
let proc = spawn([ | ||
"docker", | ||
"ps", | ||
"-a", | ||
"-q", | ||
"--filter", | ||
`label=modules-test`, | ||
]); | ||
let containerIDsRaw = await readableStreamToText(proc.stdout); | ||
let exitCode = await proc.exited; | ||
if (exitCode !== 0) { | ||
throw new Error(containerIDsRaw); | ||
} | ||
containerIDsRaw = containerIDsRaw.trim(); | ||
if (containerIDsRaw === "") { | ||
return; | ||
} | ||
proc = spawn(["docker", "rm", "-f", ...containerIDsRaw.split("\n")]); | ||
const stdout = await readableStreamToText(proc.stdout); | ||
exitCode = await proc.exited; | ||
if (exitCode !== 0) { | ||
throw new Error(stdout); | ||
} | ||
}; | ||
|
||
afterAll(async () => { | ||
await Promise.all([removeStatefiles(), removeOldContainers()]); | ||
}); |
Oops, something went wrong.