test: provide a MySQL service for CI coverage tests #3573
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dozer Coverage | |
on: | |
workflow_dispatch: | |
pull_request_target: | |
branches: [main] | |
merge_group: | |
env: | |
CARGO_TERM_COLOR: always | |
concurrency: | |
group: coverage/${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: write # This is required for actions/checkout | |
jobs: | |
# Run coverage | |
coverage: | |
timeout-minutes: 60 | |
runs-on: | |
group: Org Larger Runners | |
labels: ubuntu-latest-16-cores | |
services: | |
postgres: | |
image: debezium/postgres:13 | |
ports: | |
- 5434:5432 | |
env: | |
POSTGRES_DB: dozer_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ALLOW_IP_RANGE: 0.0.0.0/0 | |
# command: postgres -c hba_file=/var/lib/stock-sample/pg_hba.conf | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
mysql: | |
image: mysql:8 | |
ports: | |
- 3306:3306 | |
env: | |
MYSQL_ROOT_PASSWORD: mysql | |
MYSQL_ROOT_HOST: '%' | |
MYSQL_DATABASE: test | |
options: >- | |
--health-cmd "mysqladmin ping -uroot --password=mysql" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-session-name: dozer-coverage | |
aws-region: us-east-2 | |
- if: github.event_name == 'pull_request_target' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- if: github.event_name != 'pull_request_target' | |
uses: actions/checkout@v3 | |
- name: Install stable with llvm-tools-preview | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: llvm-tools-preview | |
- name: Download grcov | |
run: | | |
mkdir target | |
wget -O target/grcov https://dozer-ci.s3.ap-southeast-1.amazonaws.com/grcov-linux-amd64-v0.8.13 | |
chmod +x target/grcov | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: ⚡ Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
~/.cargo/.package-cache | |
~/.cargo/registry/ | |
~/.cargo/git/db/ | |
target/ | |
key: coverage-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
restore-keys: | | |
coverage-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
coverage-${{ runner.os }}-cargo- | |
- name: MongoDB in GitHub Actions | |
uses: supercharge/[email protected] | |
- uses: ./.github/workflows/setup-snowflake-and-kafka | |
- name: Run connectors tests | |
env: | |
CARGO_INCREMENTAL: "0" | |
RUSTFLAGS: "-Cinstrument-coverage" | |
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" | |
SN_SERVER: ${{ secrets.SN_SERVER }} | |
SN_USER: ${{ secrets.SN_USER }} | |
SN_PASSWORD: ${{ secrets.SN_PASSWORD }} | |
SN_DATABASE: ${{ secrets.SN_DATABASE }} | |
SN_WAREHOUSE: ${{ secrets.SN_WAREHOUSE }} | |
SN_DRIVER: ${{ secrets.SN_DRIVER }} | |
shell: bash | |
run: | | |
cargo test test_connector_ --lib --features snowflake,ethereum,kafka,python --no-fail-fast -- --ignored | |
- name: Run tests | |
env: | |
CARGO_INCREMENTAL: "0" | |
RUSTFLAGS: "-Cinstrument-coverage" | |
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" | |
shell: bash | |
run: | | |
source ./dozer-tests/python_udf/virtualenv.sh | |
cargo test --features snowflake,ethereum,kafka,python,mongodb --no-fail-fast | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- id: coverage | |
run: | | |
./target/grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" --ignore 'target/*' --ignore 'dozer-tests/*' -o coverage.lcov | |
echo "::set-output name=report::coverage.lcov" | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: | | |
${{ steps.coverage.outputs.report }} | |
retention-days: 10 | |
- if: github.event_name == 'pull_request_target' | |
name: Coveralls upload | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: ${{ steps.coverage.outputs.report }} | |
git-commit: ${{ github.event.pull_request.head.sha }} | |
- if: github.event_name != 'pull_request_target' | |
name: Coveralls upload | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: ${{ steps.coverage.outputs.report }} | |
discord_notification: | |
if: ${{ github.event_name == 'push' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Discord notification | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBOOK }} | |
DISCORD_EMBEDS: '[ { | |
"title": " ${{ github.actor }} pushed to `${{ github.ref_name }}` :rocket:", | |
"author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{ github.actor }}" }, | |
"fields": [ | |
{ "name": "Commit", "value": "[${{ github.event.head_commit.id }}](${{ github.event.head_commit.url }})"}, | |
{ "name": "Repository", "value": "[getdozer/dozer](https://github.com/getdozer/dozer)" }, | |
{ "name": "Message", "value": ${{ toJSON(github.event.head_commit.message) }}} | |
], | |
"color": 990099 | |
}]' | |
uses: Ilshidur/action-discord@master |