Skip to content
Open
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
72 changes: 41 additions & 31 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ jobs:
env:
BUILD_TAG: 0.0.0
SHORTCOMMIT: "0000000"
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # ratchet:actions/setup-go@v6
with:
fetch-depth: 0
go-version-file: go.mod
cache: false

# setup-go sets GOTOOLCHAIN=local; override so sub-module tools
# with newer go directives can auto-download.
- name: Override GOTOOLCHAIN
run: echo "GOTOOLCHAIN=auto" >> "$GITHUB_ENV"

- uses: ./.github/actions/job-preamble
with:
Expand Down Expand Up @@ -115,37 +118,38 @@ jobs:
env:
BUILD_TAG: 0.0.0
SHORTCOMMIT: "0000000"
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Set Postgres version
run: |
echo "/usr/pgsql-${{ matrix.pg }}/bin" >> "${GITHUB_PATH}"

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # ratchet:actions/setup-go@v6
with:
fetch-depth: 0
go-version-file: go.mod
cache: false

- name: Override GOTOOLCHAIN
run: echo "GOTOOLCHAIN=auto" >> "$GITHUB_ENV"

- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}

# trust: allow passwordless local connections (tests don't configure a password)
# locale=C: tests (e.g. central/splunk) assume byte-order collation for ID comparisons
- name: Run Postgres
run: |
su postgres -c 'initdb -D /tmp/data'
su postgres -c 'pg_ctl -D /tmp/data start'
docker run --rm -d --name postgres --network=host \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_INITDB_ARGS="--locale=C" \
docker.io/library/postgres:${{ matrix.pg }}

- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies
with:
key-suffix: ${{ matrix.gotags }}

- name: Is Postgres ready
run: pg_isready -h 127.0.0.1
run: pg_isready -h 127.0.0.1 --timeout=60 || { docker logs postgres; exit 1; }

- name: Go Unit Tests
run: ${{ matrix.gotags }} make go-postgres-unit-tests
Expand Down Expand Up @@ -177,36 +181,42 @@ jobs:
directory: 'junit-reports'

go-bench:
strategy:
matrix:
pg: [ '15' ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add matrix here then we need to change required jobs. Let's skip it for now and hardcode 15 as any failures should be caught in unit tests, here we only validate if bench tests are runable.

runs-on: ubuntu-latest
container:
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3@sha256:39fd328dcc903b7d8a2f3eb6d9e5ddbf79569227a5667296b4b927f74c11b32a # ratchet:quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.3
volumes:
- /usr:/mnt/usr
- /opt:/mnt/opt
steps:
- name: Set Postgres version
run: |
echo "/usr/pgsql-15/bin" >> "${GITHUB_PATH}"

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
fetch-depth: 0

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # ratchet:actions/setup-go@v6
with:
go-version-file: go.mod
cache: false

- name: Override GOTOOLCHAIN
run: echo "GOTOOLCHAIN=auto" >> "$GITHUB_ENV"

- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}

# trust: allow passwordless local connections (tests don't configure a password)
# locale=C: tests (e.g. central/splunk) assume byte-order collation for ID comparisons
- name: Run Postgres
run: |
su postgres -c 'initdb -D /tmp/data'
su postgres -c 'pg_ctl -D /tmp/data start'
docker run --rm -d --name postgres --network=host \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_INITDB_ARGS="--locale=C" \
docker.io/library/postgres:${{ matrix.pg }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use our own image? Or maybe the db we are using in upstream?

FROM quay.io/sclorg/postgresql-${PG_VERSION}-c9s:latest AS final

The problem with docker.io is that we need to login first to prevent rate-limits. Al


- name: Cache Go dependencies
uses: ./.github/actions/cache-go-dependencies

- name: Is Postgres ready
run: pg_isready -h 127.0.0.1
run: pg_isready -h 127.0.0.1 --timeout=60 || { docker logs postgres; exit 1; }

- name: Go Bench Tests
run: make go-postgres-bench-tests
Expand Down
Loading