diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f1fb63..8eccd2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -26,7 +26,7 @@ jobs: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Run goimports - run: goimports -local github.com/yourusername/yourrepo -d . + run: goimports -local github.com/digitaldrywood/github-integration-testing-demo -d . - name: Run go vet run: go vet ./... @@ -40,7 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -48,7 +48,7 @@ jobs: run: go test -v -race -coverprofile=coverage.txt ./... - name: Upload coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: file: ./coverage.txt @@ -62,7 +62,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -72,50 +72,28 @@ jobs: go build -o dist/app-${{ matrix.os }}-${{ matrix.arch }} ./src - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: binaries + name: binary-${{ matrix.os }}-${{ matrix.arch }} path: dist/ - # This job always runs but only does actual testing on main branch - integration-test-mock: - name: Integration Tests (Mock) + # This job runs simulated integration tests that don't require external services + integration-test-simulated: + name: Integration Tests (Simulated) runs-on: ubuntu-latest needs: [lint, test] steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - name: Start mock S3 server + - name: Run simulated integration tests run: | - docker run -d \ - -p 9000:9000 \ - -e MINIO_ROOT_USER=minioadmin \ - -e MINIO_ROOT_PASSWORD=minioadmin \ - --name minio \ - minio/minio server /data - - - name: Wait for mock server - run: | - for i in {1..30}; do - if curl -s http://localhost:9000/minio/health/ready; then - break - fi - sleep 1 - done - - - name: Run integration tests with mock - run: | - go test -v ./tests -tags=integration -s3 \ - -endpoint=http://localhost:9000 \ - -bucket=test-bucket + go test -v ./tests -tags=integration -storage -database -api \ + -timeout=5m env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - - - name: Cleanup - if: always() - run: docker stop minio && docker rm minio \ No newline at end of file + STORAGE_TYPE: mock-s3 + DB_TYPE: mock-postgres + API_TYPE: mock-rest \ No newline at end of file diff --git a/.github/workflows/integration-manual.yml b/.github/workflows/integration-manual.yml index db8c121..7828004 100644 --- a/.github/workflows/integration-manual.yml +++ b/.github/workflows/integration-manual.yml @@ -88,7 +88,7 @@ jobs: ref: ${{ needs.setup.outputs.ref }} - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -106,7 +106,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: storage-test-results path: | @@ -126,7 +126,7 @@ jobs: ref: ${{ needs.setup.outputs.ref }} - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -144,7 +144,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: database-test-results path: | @@ -164,7 +164,7 @@ jobs: ref: ${{ needs.setup.outputs.ref }} - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -182,7 +182,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: api-test-results path: | @@ -196,7 +196,7 @@ jobs: if: always() steps: - name: Download all artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 - name: Generate summary run: | @@ -224,7 +224,7 @@ jobs: - name: Comment on PR (if applicable) if: github.event.inputs.pr_number != '' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const pr_number = ${{ github.event.inputs.pr_number }}; diff --git a/src/main.go b/src/main.go index 3204be1..06658b0 100644 --- a/src/main.go +++ b/src/main.go @@ -128,7 +128,9 @@ func LoadServiceConfig() []ServiceConfig { } func main() { - rand.Seed(time.Now().UnixNano()) + // Initialize random number generator + // Note: As of Go 1.20, rand.Seed is deprecated and not needed + // The random number generator is automatically seeded ctx := context.Background() fmt.Println("=== Integration Testing Demo ===") diff --git a/tests/integration_test.go b/tests/integration_test.go index 417b652..0b7e6a7 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -363,6 +363,6 @@ func TestIntegrationSuite(t *testing.T) { } func init() { - // Initialize random seed for failure simulation - rand.Seed(time.Now().UnixNano()) + // Random number generator is automatically seeded in Go 1.20+ + // No need to call rand.Seed } \ No newline at end of file