Skip to content
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
56 changes: 17 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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 ./...
Expand All @@ -40,15 +40,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Run unit tests
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

Expand All @@ -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 }}

Expand All @@ -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
STORAGE_TYPE: mock-s3
DB_TYPE: mock-postgres
API_TYPE: mock-rest
16 changes: 8 additions & 8 deletions .github/workflows/integration-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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: |
Expand All @@ -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 }}

Expand All @@ -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: |
Expand All @@ -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 }}

Expand All @@ -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: |
Expand All @@ -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: |
Expand Down Expand Up @@ -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 }};
Expand Down
4 changes: 3 additions & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===")
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading