Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #92: Run indexing in GitHub Actions #94

Merged
8 commits merged into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -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: 'backend/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
Yantrio marked this conversation as resolved.
Show resolved Hide resolved
go run github.com/opentofu/registry-ui/cmd/generate --log-level=trace --namespace="${NAMESPACE}" --s3-bucket=${S3_BUCKET}
done
40 changes: 40 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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: 'backend/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: 'backend/go.mod'
- name: Run go generate
working-directory: backend
run: go generate ./...
- name: Run tests
working-directory: backend
run: |
go test ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/work
/docs
/registry
.idea
2 changes: 1 addition & 1 deletion backend/internal/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 0 additions & 18 deletions backend/internal/indexstorage/bufferedstorage/buffered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions backend/internal/indexstorage/s3storage/direct_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package s3storage_test

import (
"context"
"crypto/tls"
"crypto/x509"
"os"
Expand All @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module "foo" {
source = "./module"
version = "1.0.0"

test = "Hello world!"
}
Loading