From 41a458c5df2b18c9f8e1d4422dab62f40508b060 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:55:34 +0200 Subject: [PATCH 1/8] Fixes #92: Run indexing in GitHub Actions Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .github/workflows/generate.yml | 29 ++++++++++++++++++++++++++ .github/workflows/verify.yml | 37 ++++++++++++++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 67 insertions(+) create mode 100644 .github/workflows/generate.yml create mode 100644 .github/workflows/verify.yml diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 00000000..76b22490 --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,29 @@ +name: Generate +permissions: {} +on: + schedule: + - cron: "0 * * *" +jobs: + generate: + name: Run generation + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Run generation + working-directory: backend + env: + AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} + AWS_ENDPOINT_URL_S3: ${{secrets.AWS_ENDPOINT_URL_S3}} + AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} + S3_BUCKET: ${{secrets.S3_BUCKET}} + NAMESPACES: hashicorp,opentofu,env0,spacelift-io,scalr,harness-io,integrations + run: | + mkdir work + for NAMESPACE in ${NAMESPACES}; do + go run github.com/opentofu/registry-ui/cmd/generate --log-level=trace --namespace="${NAMESPACE}" --s3-bucket=${S3_BUCKET} + done diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 00000000..d94a2aa9 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,37 @@ +name: Verify +permissions: {} +on: + pull_request: +jobs: + generate: + name: Go generate + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Run go generate + working-directory: backend + run: go generate ./... + - name: Check if there are any changes + run: | + if [ "$(git diff | wc -l)" -ne 0 ]; then + echo "Changes detected after go generate. Please run go generate ./... and push your changes." + fi + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Run tests + working-directory: backend + run: | + go test ./... diff --git a/.gitignore b/.gitignore index 09671c56..022e6460 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /work /docs /registry +.idea \ No newline at end of file From 54b1399dfd985a50aa24d1d083ddbde8ace57d22 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:56:54 +0200 Subject: [PATCH 2/8] Fixed go installation Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .github/workflows/generate.yml | 2 +- .github/workflows/verify.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 76b22490..1599b477 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -13,7 +13,7 @@ jobs: - name: Setup go uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version-file: 'backend/go.mod' - name: Run generation working-directory: backend env: diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index d94a2aa9..8ec79e4f 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -12,7 +12,7 @@ jobs: - name: Setup go uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version-file: 'backend/go.mod' - name: Run go generate working-directory: backend run: go generate ./... @@ -30,7 +30,7 @@ jobs: - name: Setup go uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version-file: 'backend/go.mod' - name: Run tests working-directory: backend run: | From 07015da6348e5c2ad6a41f1a0b0e079fe3d8c594 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:57:33 +0200 Subject: [PATCH 3/8] Cron trigger Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .github/workflows/generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 1599b477..d22c139c 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -2,7 +2,7 @@ name: Generate permissions: {} on: schedule: - - cron: "0 * * *" + - cron: "0 * * * *" jobs: generate: name: Run generation From 7deafad535fb373e41d44ad8e95fc2c488de7d63 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:01:18 +0200 Subject: [PATCH 4/8] Fixed namespaces Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .github/workflows/generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index d22c139c..e473e44a 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -21,7 +21,7 @@ jobs: AWS_ENDPOINT_URL_S3: ${{secrets.AWS_ENDPOINT_URL_S3}} AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} S3_BUCKET: ${{secrets.S3_BUCKET}} - NAMESPACES: hashicorp,opentofu,env0,spacelift-io,scalr,harness-io,integrations + NAMESPACES: hashicorp opentofu env0 spacelift-io scalr harness-io integrations run: | mkdir work for NAMESPACE in ${NAMESPACES}; do From 9ce57626f0b649b02794113a454152151829dd01 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:02:02 +0200 Subject: [PATCH 5/8] Fixed tests Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .github/workflows/verify.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 8ec79e4f..26428b2f 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -31,6 +31,9 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: 'backend/go.mod' + - name: Run go generate + working-directory: backend + run: go generate ./... - name: Run tests working-directory: backend run: | From f59e54ffe5c66ebf8935b07667369ff58c55b0aa Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:14:53 +0200 Subject: [PATCH 6/8] Bugfixes Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- backend/internal/factory/factory.go | 2 +- backend/internal/indexstorage/s3storage/direct_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/internal/factory/factory.go b/backend/internal/factory/factory.go index 5193a1c6..f2220235 100644 --- a/backend/internal/factory/factory.go +++ b/backend/internal/factory/factory.go @@ -109,7 +109,7 @@ func getBackend(ctx context.Context, log logger.Logger, registryDir string, work backingStorage, err = s3storage.New( ctx, s3storage.WithBucket(s3Params.Bucket), - //s3storage.WithRegion(s3Params.Region), + s3storage.WithRegion(s3Params.Region), s3storage.WithEndpoint(s3Params.Endpoint), s3storage.WithTLSConfig(&tls.Config{ RootCAs: tlsPool, diff --git a/backend/internal/indexstorage/s3storage/direct_test.go b/backend/internal/indexstorage/s3storage/direct_test.go index ccc055a4..7e8a8acb 100644 --- a/backend/internal/indexstorage/s3storage/direct_test.go +++ b/backend/internal/indexstorage/s3storage/direct_test.go @@ -1,6 +1,7 @@ package s3storage_test import ( + "context" "crypto/tls" "crypto/x509" "os" @@ -20,6 +21,7 @@ func TestDirect(t *testing.T) { certPool := x509.NewCertPool() certPool.AppendCertsFromPEM(aws.CACert()) storage := tofutestutils.Must2(s3storage.New( + context.Background(), s3storage.WithBucket(aws.S3Bucket()), s3storage.WithAccessKey(aws.AccessKey()), s3storage.WithSecretKey(aws.SecretKey()), From 5b018beb31d46cc979c904a9a8480ea587368719 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:05:40 +0200 Subject: [PATCH 7/8] Removing obsolete TestChecksum test Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .../bufferedstorage/buffered_test.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/backend/internal/indexstorage/bufferedstorage/buffered_test.go b/backend/internal/indexstorage/bufferedstorage/buffered_test.go index d66a8c7f..0a0bc299 100644 --- a/backend/internal/indexstorage/bufferedstorage/buffered_test.go +++ b/backend/internal/indexstorage/bufferedstorage/buffered_test.go @@ -129,24 +129,6 @@ func TestSubdir(t *testing.T) { assertFileExists(t, ctx, buffer, "test/test.txt") } -func TestChecksum(t *testing.T) { - const testFile = "test.txt" - const testContent = "Hello world!" - backingDir := t.TempDir() - backingStorage := tofutestutils.Must2(filesystemstorage.New(backingDir)) - buffer := tofutestutils.Must2(bufferedstorage.New(logger.NewTestLogger(t), t.TempDir(), backingStorage, 25)) - - ctx := tofutestutils.Context(t) - - tofutestutils.Must(backingStorage.WriteFile(ctx, testFile, []byte(testContent))) - - tofutestutils.Must(buffer.WriteFile(ctx, testFile, []byte(testContent))) - - if buffer.UncommittedFiles() != 0 { - t.Fatalf("There are uncommitted files in the buffer!") - } -} - func assertFileDoesNotExist(t *testing.T, ctx context.Context, storage indexstorage.API, file indexstorage.Path) { t.Helper() _, err := storage.ReadFile(ctx, file) From b64dc676cd9e40a02846384064890b38547cd791 Mon Sep 17 00:00:00 2001 From: Janos <86970079+janosdebugs@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:18:18 +0200 Subject: [PATCH 8/8] Fixed modulecall test Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> --- .../moduleindex/moduleschema/testdata/modulecall/modulecall.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/internal/moduleindex/moduleschema/testdata/modulecall/modulecall.tf b/backend/internal/moduleindex/moduleschema/testdata/modulecall/modulecall.tf index e5b3fc7a..a07e29b0 100644 --- a/backend/internal/moduleindex/moduleschema/testdata/modulecall/modulecall.tf +++ b/backend/internal/moduleindex/moduleschema/testdata/modulecall/modulecall.tf @@ -1,6 +1,5 @@ module "foo" { source = "./module" - version = "1.0.0" test = "Hello world!" } \ No newline at end of file