Skip to content

Commit

Permalink
add coverage report and readme
Browse files Browse the repository at this point in the history
Fix coverage report
  • Loading branch information
amishas157 committed Aug 8, 2024
1 parent eb0bfad commit 0abc22c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up Docker Compose
run: |
sudo apt-get update
Expand All @@ -41,7 +38,31 @@ jobs:

- name: Run tests
run: |
docker-compose run -v ${{ runner.workspace }}/gcp-key.json:/usr/credential.json:ro -e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json integration-tests go test -v -cover ./cmd -timeout 30m
docker-compose run -v ${{ runner.workspace }}/gcp-key.json:/usr/credential.json:ro \
-v ${{ runner.workspace }}/coverage.out:/usr/coverage.out \
-e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json \
integration-tests \
go test -v -coverprofile=/usr/coverage.out ./cmd ./internal/transform -timeout 30m
- name: Generate Coverage Report
run: |
go tool cover -func=${{ runner.workspace }}/coverage.out
- name: Check Coverage
id: coverage
run: |
COVERAGE=$(go tool cover -func=${{ runner.workspace }}/coverage.out | grep total: | awk '{print $3}' | sed 's/%//')
echo "Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 60" | bc -l) )); then
echo "Coverage is below the 60% threshold."
exit 1
fi
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ${{ runner.workspace }}/coverage.out

- name: Stop and remove containers
run: |
Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ docker-build:
docker-push:
$(SUDO) docker push $(ETLHASH)
$(SUDO) docker push stellar/stellar-etl:latest

int-test:
docker-compose build
docker-compose run \
-v $(HOME)/.config/gcloud/application_default_credentials.json:/usr/credential.json:ro \
-v $(PWD)/testdata:/usr/src/etl/testdata \
-e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json \
integration-tests \
go test -v ./cmd -timeout 30m

int-test-update:
docker-compose build
docker-compose run \
-v $(HOME)/.config/gcloud/application_default_credentials.json:/usr/credential.json:ro \
-v $(PWD)/testdata:/usr/src/etl/testdata \
-e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json \
integration-tests \
go test -v ./cmd -timeout 30m -args -update=true
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,46 @@ Add following to docker run command to pass gcloud credentials to docker contain
<br>

## **Running Tests**

### Unit tests

```sh
# Running all unit tests
go test -v -cover ./internal/transform

# Running an individual test
go test -v -run ^TestTransformAsset$ ./internal/transform
```

### Integration tests

```sh
# Running all integration tests
make int-test

# Running all integration tests and update golden files
make int-test-update

# Above essentially runs following:
docker-compose build
docker-compose run \
-v $(HOME)/.config/gcloud/application_default_credentials.json:/usr/credential.json:ro \
-v $(PWD)/testdata:/usr/src/etl/testdata \
-e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json \
integration-tests \
go test -v ./cmd -timeout 30m -args -update=true

# Running an individual test
docker-compose build
docker-compose run \
-v $(HOME)/.config/gcloud/application_default_credentials.json:/usr/credential.json:ro \
-v $(PWD)/testdata:/usr/src/etl/testdata \
-e GOOGLE_APPLICATION_CREDENTIALS=/usr/credential.json \
integration-tests \
go test -v -run ^TestExportAssets$ ./cmd -timeout 30m -args -update=true
```

---

# **Command Reference**
Expand Down

0 comments on commit 0abc22c

Please sign in to comment.