Skip to content

Commit

Permalink
Github Actions: split testing and releasing (close #806)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjben committed Jul 19, 2023
1 parent 1ff9a79 commit c9266b0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 71 deletions.
72 changes: 1 addition & 71 deletions .github/workflows/ci.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,14 @@
name: CI
name: release

on:
push:
tags:
- '*'
branches:
- master
- develop
- 'snapshot/**'
pull_request:

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: enricher
POSTGRES_PASSWORD: supersecret1
POSTGRES_DB: sql_enrichment_test
POSTGRES_PORT: 5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v6
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Start HTTP server to test API enrichment in Common Enrich
run: python integration-tests/common/api-enrichment-test.py 8001 &
- name: Start HTTP server to test API enrichment in Common Fs2
run: python integration-tests/common-fs2/api-enrichment-test.py 8000 &
- name: Prepare data in Postgres to test SQL enrichment in Common Enrich
run: psql -h localhost -p 5432 -U enricher -d sql_enrichment_test < integration-tests/common/sql-enrichment-test.sql
env:
PGPASSWORD: supersecret1
- name: Prepare data in Postgres to test SQL enrichment in Common Fs2
run: psql -h localhost -p 5432 -U enricher -d sql_enrichment_test < integration-tests/common-fs2/sql-enrichment-test.sql
env:
PGPASSWORD: supersecret1
- name: Run tests
run: SBT_OPTS="-Xms1G -Xmx8G -Xss4M -XX:MaxMetaspaceSize=1024M" sbt coverage +test
env:
OER_KEY: ${{ secrets.OER_KEY }}
- name: Check Scala formatting
run: sbt scalafmtCheckAll
- name: Check assets can be published
run: sbt publishLocal
- name: Run integration tests for enrich-kinesis
run: sbt "project kinesisDistroless" IntegrationTest/test
env:
AWS_ACCESS_KEY_ID: foo
AWS_SECRET_ACCESS_KEY: bar
- name: Run integration tests for enrich-kafka
run: |
sbt "project kafka" "docker:publishLocal"
docker-compose -f integration-tests/enrich-kafka/docker-compose.yml up -d
sbt "project kafka" IntegrationTest/test
docker-compose -f integration-tests/enrich-kafka/docker-compose.yml down
- name: Run integration tests for enrich-nsq
run: sbt "project nsqDistroless" IntegrationTest/test
- name: Generate coverage report
run: sbt coverageReport
- name: Aggregate coverage data
run: sbt coverageAggregate
- name: Submit coveralls data
run: sbt coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

github_release:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -119,7 +51,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish_docker:
needs: test
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/snapshot')
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -247,7 +178,6 @@ jobs:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

publish_sce:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: test

on:
push:
branches:
- '**'
tags-ignore:
- '**'

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: enricher
POSTGRES_PASSWORD: supersecret1
POSTGRES_DB: sql_enrichment_test
POSTGRES_PORT: 5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v6
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Start HTTP server to test API enrichment in Common Enrich
run: python integration-tests/common/api-enrichment-test.py 8001 &
- name: Start HTTP server to test API enrichment in Common Fs2
run: python integration-tests/common-fs2/api-enrichment-test.py 8000 &
- name: Prepare data in Postgres to test SQL enrichment in Common Enrich
run: psql -h localhost -p 5432 -U enricher -d sql_enrichment_test < integration-tests/common/sql-enrichment-test.sql
env:
PGPASSWORD: supersecret1
- name: Prepare data in Postgres to test SQL enrichment in Common Fs2
run: psql -h localhost -p 5432 -U enricher -d sql_enrichment_test < integration-tests/common-fs2/sql-enrichment-test.sql
env:
PGPASSWORD: supersecret1
- name: Run tests
run: SBT_OPTS="-Xms1G -Xmx8G -Xss4M -XX:MaxMetaspaceSize=1024M" sbt coverage +test
env:
OER_KEY: ${{ secrets.OER_KEY }}
- name: Check Scala formatting
run: sbt scalafmtCheckAll
- name: Check assets can be published
run: sbt publishLocal
- name: Run integration tests for enrich-kinesis
run: sbt "project kinesisDistroless" IntegrationTest/test
env:
AWS_ACCESS_KEY_ID: foo
AWS_SECRET_ACCESS_KEY: bar
- name: Run integration tests for enrich-kafka
run: |
sbt "project kafka" "docker:publishLocal"
docker-compose -f integration-tests/enrich-kafka/docker-compose.yml up -d
sbt "project kafka" IntegrationTest/test
docker-compose -f integration-tests/enrich-kafka/docker-compose.yml down
- name: Run integration tests for enrich-nsq
run: sbt "project nsqDistroless" IntegrationTest/test
- name: Generate coverage report
run: sbt coverageReport
- name: Aggregate coverage data
run: sbt coverageAggregate
- name: Submit coveralls data
run: sbt coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

0 comments on commit c9266b0

Please sign in to comment.