Skip to content

adding support for scripts + tests #6

adding support for scripts + tests

adding support for scripts + tests #6

Workflow file for this run

# Copyright 2023 The Cockroach Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: DB2 Tests
permissions:
contents: read
packages: read
# on:
# workflow_call:
# workflow_dispatch:
on:
push:
branches: [ sr8_db2 ]
jobs:
# Static code-quality checks.
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: crlfmt returns no deltas
if: ${{ !cancelled() }}
run: |
DELTA=$(go run github.com/cockroachdb/crlfmt -ignore _gen.go .)
echo $DELTA
test -z "$DELTA"
- name: Copyright headers
if: ${{ !cancelled() }}
run: go run github.com/google/addlicense -c "The Cockroach Authors" -l apache -s -v -check -ignore ".github/db2/**" -ignore '**/testdata/**/*.sql' .
- name: Lint
if: ${{ !cancelled() }}
run: go run golang.org/x/lint/golint -set_exit_status ./...
- name: Static checks
if: ${{ !cancelled() }}
run: go run honnef.co/go/tools/cmd/staticcheck -checks all ./...
- name: Go Vet
if: ${{ !cancelled() }}
run: go vet ./...
# Check that all dependencies have licenses and that those
# licenses are reasonably permissive. License files for modules
# reachable from the entry point will be bundled and are visible
# through the licenses subcommand.
- name: License Checks
if: ${{ !cancelled() }}
run: go run github.com/google/go-licenses check .
- name: Ensure binary starts
if: ${{ !cancelled() }}
run: go run . help
# Integration matrix tests for all supported CRDB and source DBs.
tests:
name: Integration Tests
runs-on: ${{ matrix.runs-on || 'ubuntu-latest-8-core' }}
timeout-minutes: 20
strategy:
fail-fast: false
# Refer to the CRDB support policy when determining how many
# older releases to support.
# https://www.cockroachlabs.com/docs/releases/release-support-policy.html
#
# This matrix is explicit, since we have a few axes (target vs
# integration) that can't be expressed with the automatic
# cross-product behavior provided by the matrix operator.
matrix:
include:
- cockroachdb: v23.1
integration: db2-v11.5.9
env:
COVER_OUT: coverage-${{ strategy.job-index }}.out
DOCKER_LOGS_OUT: docker-${{ strategy.job-index }}.log
FIRESTORE_EMULATOR_HOST: 127.0.0.1:8181
JUNIT_OUT: junit-${{ strategy.job-index }}.xml
TEST_OUT: go-test-${{ strategy.job-index }}.json
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# Ensure we can grab any private images we need for testing.
- name: Log in to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Start Containers
working-directory: .github
run: >
docker compose up -d --wait
cockroachdb-${{ matrix.cockroachdb }}
${{ matrix.integration }}
${{ matrix.source }}
${{ matrix.target }}
# The go test json output will be written into a pipeline to
# create a JUnit.xml file. The test reports are aggregated later
# on to produce a nicer summary of the test output in the GitHub
# Actions UI.
#
# Inspired by
# https://www.cloudwithchris.com/blog/githubactions-testsummary-go/
- name: Go Tests
env:
COCKROACH_DEV_LICENSE: ${{ secrets.COCKROACH_DEV_LICENSE }}
CDC_INTEGRATION: ${{ matrix.integration }}
TEST_SOURCE_CONNECT: ${{ matrix.sourceConn }}
TEST_TARGET_CONNECT: ${{ matrix.targetConn }}
IBM_DRIVER: /tmp/drivers/clidriver
CGO_CFLAGS: -I${IBM_DRIVER}/include
CGO_LDFLAGS: -L${IBM_DRIVER}/lib
run: >
set -o pipefail;
make testdb2 2>&1 |
go run github.com/jstemmer/go-junit-report/v2
-iocopy
-out ${{ env.JUNIT_OUT }}
-p cockroachdb=${{ matrix.cockroachdb }}
-p integration=${{ matrix.integration }}
-package-name ${{ matrix.cockroachdb }}-${{ matrix.integration }} |
tee ${{ env.TEST_OUT }}
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.COVER_OUT }}
# Capture container logs in case they're needed for diagnostics.
- name: Docker container logs
if: always()
working-directory: .github
run: docker-compose logs --no-color > ${{ env.DOCKER_LOGS_OUT }}
# Upload all test reports to a common artifact name, to make them
# available to the summarization step. The go test json is
# uploaded as a developer convenience.
- name: Stash test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: integration-reports
path: |
${{ env.COVER_OUT }}
${{ env.DOCKER_LOGS_OUT }}
${{ env.JUNIT_OUT }}
${{ env.TEST_OUT }}
retention-days: 7
# Aggregate the results of multiple jobs within this workflow into a
# single status object that we can use for branch protection.
#
# https://docs.github.com/en/rest/commits/statuses
status:
name: Create status objects
runs-on: ubuntu-latest
permissions:
statuses: write
needs: # Update failure case below
- code-quality
- tests
if: ${{ always() }}
env:
CONTEXT: Workflow Golang
GH_TOKEN: ${{ github.token }}
MERGE_SHA: ${{ github.event.merge_group.head_sha }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
STATE: success
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Failure
if: ${{ needs.code-quality.result != 'success' || needs.tests.result != 'success' }}
run: echo "STATE=failure" >> $GITHUB_ENV
- name: Report
run: |
set -eo pipefail
if [ ! -z "$PR_SHA" ]; then
gh api \
repos/${{ github.repository }}/statuses/$PR_SHA \
-f "state=$STATE" \
-f "context=$CONTEXT" \
-f "target_url=$RUN_URL"
fi
if [ ! -z "$MERGE_SHA" ]; then
gh api \
repos/${{ github.repository }}/statuses/$MERGE_SHA \
-f "state=$STATE" \
-f "context=$CONTEXT" \
-f "target_url=$RUN_URL"
fi
# This job downloads the test log files generated in the integration
# job and summarizes them into the GitHub Actions UI.
summarize-tests:
name: Test summaries
runs-on: ubuntu-latest
needs: tests
if: ${{ always() }}
steps:
- name: Download reports
uses: actions/download-artifact@v3
with:
name: integration-reports
- name: Summarize
uses: test-summary/action@v2
with:
paths: junit-*.xml