2023-01-05 15:08:40 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
//go:generate go run ./main.go
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
jobFileNameTemplate = `test-integration-v2-%s.yaml`
|
|
|
|
jobTemplate = template.Must(template.New("jobTemplate").Parse(`
|
|
|
|
# DO NOT EDIT, generated with cmd/gh-action-integration-generator/main.go
|
|
|
|
# To regenerate, run "go generate" in cmd/gh-action-integration-generator/
|
|
|
|
|
|
|
|
name: Integration Test v2 - {{.Name}}
|
|
|
|
|
|
|
|
on: [pull_request]
|
|
|
|
|
2023-01-30 09:20:08 +00:00
|
|
|
concurrency:
|
|
|
|
group: {{ "${{ github.workflow }}-$${{ github.head_ref || github.run_id }}" }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-01-05 15:08:40 +00:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Get changed files
|
|
|
|
id: changed-files
|
|
|
|
uses: tj-actions/changed-files@v34
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
*.nix
|
|
|
|
go.*
|
|
|
|
**/*.go
|
|
|
|
integration_test/
|
|
|
|
config-example.yaml
|
|
|
|
|
2023-01-30 09:20:08 +00:00
|
|
|
- uses: cachix/install-nix-action@v18
|
|
|
|
if: {{ "${{ env.ACT }}" }} || steps.changed-files.outputs.any_changed == 'true'
|
2023-01-05 15:08:40 +00:00
|
|
|
|
|
|
|
- name: Run general integration tests
|
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
run: |
|
|
|
|
nix develop --command -- docker run \
|
|
|
|
--tty --rm \
|
|
|
|
--volume ~/.cache/hs-integration-go:/go \
|
|
|
|
--name headscale-test-suite \
|
|
|
|
--volume $PWD:$PWD -w $PWD/integration \
|
|
|
|
--volume /var/run/docker.sock:/var/run/docker.sock \
|
2023-01-30 09:20:08 +00:00
|
|
|
--volume $PWD/control_logs:/tmp/control \
|
2023-01-05 15:08:40 +00:00
|
|
|
golang:1 \
|
|
|
|
go test ./... \
|
|
|
|
-tags ts2019 \
|
|
|
|
-failfast \
|
|
|
|
-timeout 120m \
|
|
|
|
-parallel 1 \
|
2023-01-06 14:40:03 +00:00
|
|
|
-run "^{{.Name}}$"
|
2023-01-30 09:20:08 +00:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: always() && steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
with:
|
|
|
|
name: logs
|
|
|
|
path: "control_logs/*.log"
|
2023-01-05 15:08:40 +00:00
|
|
|
`))
|
|
|
|
)
|
|
|
|
|
|
|
|
const workflowFilePerm = 0o600
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
type testConfig struct {
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(kradalby): automatic fetch tests at runtime
|
|
|
|
tests := []string{
|
|
|
|
"TestAuthKeyLogoutAndRelogin",
|
|
|
|
"TestAuthWebFlowAuthenticationPingAll",
|
|
|
|
"TestAuthWebFlowLogoutAndRelogin",
|
|
|
|
"TestCreateTailscale",
|
|
|
|
"TestEnablingRoutes",
|
|
|
|
"TestHeadscale",
|
2023-01-17 16:43:44 +00:00
|
|
|
"TestUserCommand",
|
2023-01-05 15:08:40 +00:00
|
|
|
"TestOIDCAuthenticationPingAll",
|
2023-01-31 11:40:38 +00:00
|
|
|
"TestOIDCExpireNodesBasedOnTokenExpiry",
|
2023-01-05 15:08:40 +00:00
|
|
|
"TestPingAllByHostname",
|
|
|
|
"TestPingAllByIP",
|
|
|
|
"TestPreAuthKeyCommand",
|
|
|
|
"TestPreAuthKeyCommandReusableEphemeral",
|
|
|
|
"TestPreAuthKeyCommandWithoutExpiry",
|
|
|
|
"TestResolveMagicDNS",
|
|
|
|
"TestSSHIsBlockedInACL",
|
2023-01-17 16:43:44 +00:00
|
|
|
"TestSSHMultipleUsersAllToAll",
|
2023-01-05 15:08:40 +00:00
|
|
|
"TestSSHNoSSHConfigured",
|
2023-01-17 16:43:44 +00:00
|
|
|
"TestSSHOneUserAllToAll",
|
|
|
|
"TestSSUserOnlyIsolation",
|
2023-01-05 15:08:40 +00:00
|
|
|
"TestTaildrop",
|
|
|
|
"TestTailscaleNodesJoiningHeadcale",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
var content bytes.Buffer
|
|
|
|
|
|
|
|
if err := jobTemplate.Execute(&content, testConfig{
|
|
|
|
Name: test,
|
|
|
|
}); err != nil {
|
|
|
|
log.Fatalf("failed to render template: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
path := "../../.github/workflows/" + fmt.Sprintf(jobFileNameTemplate, test)
|
|
|
|
|
|
|
|
err := os.WriteFile(path, content.Bytes(), workflowFilePerm)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("failed to write github job: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|