mirror of
https://github.com/mattermost/mattermost.git
synced 2026-11-03 12:48:37 -06:00
* chore: extract install-<tool> Makefile targets
Pull each `go install` of a build tool into its own `install-<tool>`
target so the installs are declared once and reused as prerequisites,
and add `install-ci-tools` plus a `go-cache` target that pre-warms the
Go module and build caches.
Also collapse the duplicate `vet-api` target declarations into one.
* chore(ci): add restore-go-cache composite action
* chore(ci): mount warmed Go cache into run-in-buildenv
* chore(ci): add daily Go module/build cache warm workflow
* chore(ci): restore warmed Go cache read-only across server CI jobs
* Simplify Go cache key to glob-match all go.mod and go.sum files
* make GOBIN explicit
* Pass Go cache paths as step outputs, not GITHUB_ENV
restore-go-cache wrote GOMODCACHE/GOCACHE/GOBIN to GITHUB_ENV so later
steps would pick them up. zizmor flags any GITHUB_ENV write as a possible
code-execution vector, since an attacker-controlled value there can set
LD_PRELOAD or NODE_OPTIONS for every subsequent step.
Nothing untrusted reaches these particular values, but the write is also
unnecessary: expose them as action outputs and map them into the one step
that actually needs them, matching what 8f6d17d875 did for the buildenv
actions.
Only server-test-template's shard split consumes them outside the action.
Everything else either runs in the buildenv container, which gets the
container paths via explicit -e, or reads RUNNER_TEMP directly. That step
runs `go work` and shard-split.js's `go test -list` on the host, so it
takes GOMODCACHE and GOCACHE via env; GOBIN is omitted because the host
never invokes the tools in server/bin.
Also drops the `${{ github.workspace }}` interpolation in favour of the
runner's GITHUB_WORKSPACE, so no expression is expanded into the script.
zizmor now reports no findings for the action, with no ignore comment or
config entry needed.
* Note that server/bin is only a warm start
The cache key covers the Go version and go.mod/go.sum, so it doesn't
invalidate on a tools/mattermost-govet source edit or a Makefile version
pin bump. That reads like a staleness bug until you notice every consumer
re-runs its install-<tool> prerequisite, and `go install` rebuilds on
content, so a stale binary is overwritten before anything uses it.
Say so where the key is described, since it came up in review.
144 lines
5.3 KiB
YAML
144 lines
5.3 KiB
YAML
name: mmctl CI
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
name:
|
|
required: true
|
|
type: string
|
|
datasource:
|
|
required: true
|
|
type: string
|
|
drivername:
|
|
required: true
|
|
type: string
|
|
logsartifact:
|
|
required: true
|
|
type: string
|
|
build-server-tag:
|
|
description: "Build image tag (e.g. go1.26.3-node24.11.1)"
|
|
required: true
|
|
type: string
|
|
fips-enabled:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
secrets:
|
|
# Only if fips-enabled is true
|
|
DOCKERHUB_USERNAME:
|
|
required: false
|
|
DOCKERHUB_TOKEN:
|
|
required: false
|
|
# Only master / release and there is report
|
|
MM_E2E_ZEPHYR_API_KEY:
|
|
required: false
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
jobs:
|
|
test:
|
|
name: ${{ inputs.name }}
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
COMPOSE_PROJECT_NAME: ghactions
|
|
INPUT_DATASOURCE: ${{ inputs.datasource }}
|
|
INPUT_FIPS_ENABLED: ${{ inputs.fips-enabled }}
|
|
INPUT_LOGSARTIFACT: ${{ inputs.logsartifact }}
|
|
INPUT_NAME: ${{ inputs.name }}
|
|
INPUT_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
REF_NAME: ${{ github.ref_name }}
|
|
steps:
|
|
- name: buildenv/docker-login
|
|
# Only FIPS requires login for private build container. (Forks won't have credentials.)
|
|
if: inputs.fips-enabled
|
|
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Checkout mattermost project
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- name: buildenv/load
|
|
id: buildenv
|
|
uses: ./.github/actions/load-buildenv
|
|
with:
|
|
build-server-tag: ${{ inputs.build-server-tag }}
|
|
fips-enabled: ${{ inputs.fips-enabled }}
|
|
- name: Restore Go cache
|
|
uses: ./.github/actions/restore-go-cache
|
|
- name: Setup log artifact name
|
|
id: log-artifact
|
|
run: |
|
|
if [[ "$INPUT_FIPS_ENABLED" == 'true' ]]; then
|
|
echo "LOG_ARTIFACT_NAME=${INPUT_LOGSARTIFACT}-fips" >> "${GITHUB_OUTPUT}"
|
|
else
|
|
echo "LOG_ARTIFACT_NAME=${INPUT_LOGSARTIFACT}" >> "${GITHUB_OUTPUT}"
|
|
fi
|
|
|
|
- name: Store required variables for publishing results
|
|
run: |
|
|
echo "$INPUT_NAME" > server/test-name
|
|
echo "$INPUT_PR_NUMBER" > server/pr-number
|
|
- name: Run docker compose
|
|
env:
|
|
POSTGRES_PASSWORD: 'mostest_password'
|
|
run: |
|
|
cd server/build
|
|
docker compose --ansi never run --rm start_dependencies
|
|
cat ../tests/custom-schema-objectID.ldif | docker compose --ansi never exec -T openldap bash -c 'ldapadd -Y EXTERNAL -H ldapi:/// -w mostest_password || true';
|
|
cat ../tests/custom-schema-cpa.ldif | docker compose --ansi never exec -T openldap bash -c 'ldapadd -Y EXTERNAL -H ldapi:/// -w mostest_password || true';
|
|
cat ../tests/test-data.ldif | docker compose --ansi never exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest_password';
|
|
docker compose --ansi never exec -T minio sh -c 'mkdir -p /data/mattermost-test';
|
|
docker compose --ansi never ps
|
|
|
|
- name: Run mmctl Tests
|
|
env:
|
|
BUILD_IMAGE: ${{ steps.buildenv.outputs.image }}
|
|
run: |
|
|
if [[ "$REF_NAME" == 'master' ]]; then
|
|
export TESTFLAGS="-timeout 90m -race"
|
|
else
|
|
export TESTFLAGS="-timeout 30m"
|
|
fi
|
|
docker run --net ghactions_mm-test \
|
|
--ulimit nofile=8096:8096 \
|
|
--env-file=server/build/dotenv/test.env \
|
|
--env TEST_DATABASE_POSTGRESQL_DSN="$INPUT_DATASOURCE" \
|
|
--env MM_SQLSETTINGS_DATASOURCE="$INPUT_DATASOURCE" \
|
|
--env MMCTL_TESTFLAGS="$TESTFLAGS" \
|
|
--env FIPS_ENABLED="$INPUT_FIPS_ENABLED" \
|
|
--env GOMODCACHE=/gocache/mod \
|
|
--env GOCACHE=/gocache/build \
|
|
--env GOBIN=/mattermost/server/bin \
|
|
-v "${RUNNER_TEMP}/go-cache:/gocache" \
|
|
-v $PWD:/mattermost \
|
|
-w /mattermost/server \
|
|
$BUILD_IMAGE \
|
|
make test-mmctl BUILD_NUMBER=$GITHUB_HEAD_REF-$GITHUB_RUN_ID
|
|
|
|
- name: Stop docker compose
|
|
run: |
|
|
cd server/build
|
|
docker compose --ansi never stop
|
|
|
|
- name: Save mmctl test report to Zephyr Scale
|
|
if: ${{ always() && hashFiles('server/report.xml') != '' && github.event_name != 'pull_request' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) }}
|
|
uses: ./.github/actions/save-junit-report-tms
|
|
with:
|
|
report-path: server/report.xml
|
|
zephyr-api-key: ${{ secrets.MM_E2E_ZEPHYR_API_KEY }}
|
|
build-image: ${{ steps.buildenv.outputs.image }}
|
|
|
|
- name: Archive logs
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: ${{ steps.log-artifact.outputs.LOG_ARTIFACT_NAME }}
|
|
path: |
|
|
server/gotestsum.json
|
|
server/report.xml
|
|
server/test-name
|
|
server/pr-number
|