ci: add Splunk basic e2e tests #127
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: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
# It's recommended to run golangci-lint in a job separate from other jobs (go test, etc) because different jobs run in parallel. | ||
go-linter: | ||
strategy: | ||
fail-fast: false | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Pin the version in case all the builds start to fail at the same time. | ||
# There may not be an automatic way (e.g., dependabot) to update a specific parameter of a GitHub Action, | ||
# so we will just update it manually whenever it makes sense (e.g., a feature that we want is added). | ||
version: v1.54.0 | ||
args: --fix=false --timeout=5m --out-format=colored-line-number | ||
unit-tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: [ '1.20', '1.21' ] | ||
os: [ ubuntu-latest, windows-latest ] | ||
name: Unit Tests / ${{ matrix.os }} / Go ${{ matrix.go }} | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
cache: false | ||
- name: build | ||
run: make build | ||
- name: test-unit | ||
run: make test-unit | ||
e2e-tests-for-awslogs: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: [ '1.20', '1.21' ] | ||
os: [ ubuntu-latest ] # TODO: Add Windows e2e tests: https://github.com/aws/shim-loggers-for-containerd/issues/68 | ||
name: E2E tests / awslogs / ${{ matrix.os }} / Go ${{ matrix.go }} | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
cache: false | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.ROLE }} | ||
aws-region: ${{ secrets.REGION }} | ||
- name: install and start containerd | ||
shell: bash | ||
run: sudo scripts/install-containerd | ||
- name: start ecs local endpoint | ||
shell: bash | ||
run: scripts/start-ecs-local-endpoint | ||
- name: ip forwarding # awslogs driver hardcodes "169.254.170.2" as the aws credential endpoint ip so need to forward to local endpoint | ||
shell: bash | ||
run: sudo scripts/ip-forwarding | ||
- name: build | ||
run: sudo make build | ||
- name: test-e2e | ||
run: sudo -E make test-e2e-for-awslogs # containerd interaction requires sudo and aws cloudwatch interaction requires passing env vars | ||
e2e-tests-for-fluentd: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: [ '1.20', '1.21' ] | ||
os: [ ubuntu-latest ] # TODO: Add Windows e2e tests: https://github.com/aws/shim-loggers-for-containerd/issues/68 | ||
name: E2E tests / fluentd / ${{ matrix.os }} / Go ${{ matrix.go }} | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
cache: false | ||
- name: install and start containerd | ||
shell: bash | ||
run: sudo scripts/install-containerd | ||
- name: start fluentd local endpoint | ||
shell: bash | ||
run: | | ||
: # not using github action env because env map cannot be defined in terms of other vars in the map. public.ecr.aws/docker/library/fluentd:v1.16-debian-1 | ||
FLUENTD_LOG_DIR=${GITHUB_WORKSPACE}/fluentd-logs | ||
FLUENTD_PORT=24224 | ||
FLUENTD_IMAGE=public.ecr.aws/docker/library/fluentd:v1.16-debian-1 | ||
: # Fluentd container is not using root user so need 777 to make it writable. https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#docker-container-filesystem | ||
sudo mkdir -m 777 $FLUENTD_LOG_DIR | ||
docker run -d -p $FLUENTD_PORT:24224 -p $FLUENTD_PORT:24224/udp -v $FLUENTD_LOG_DIR:/fluentd/log $FLUENTD_IMAGE | ||
- name: build | ||
run: sudo make build | ||
- name: test-e2e | ||
run: sudo make test-e2e-for-fluentd # containerd interaction requires sudo | ||
e2e-tests-for-splunk: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: [ '1.20', '1.21' ] | ||
os: [ ubuntu-latest ] # TODO: Add Windows e2e tests: https://github.com/aws/shim-loggers-for-containerd/issues/68 | ||
name: E2E tests / splunk / ${{ matrix.os }} / Go ${{ matrix.go }} | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
id-token: write | ||
contents: write | ||
env: | ||
splunk-token | ||
Check failure on line 129 in .github/workflows/ci.yaml GitHub Actions / CIInvalid workflow file
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
cache: false | ||
- name: install and start containerd | ||
shell: bash | ||
run: sudo scripts/install-containerd | ||
- name: start splunk local endpoint | ||
shell: bash | ||
run: | | ||
SPLUNK_PASSWORD=1234567Aa! | ||
SPLUNK_PORT=8088 | ||
SPLUNK_IMAGE=splunk/splunk | ||
docker run -d -p $SPLUNK_PORT:8000 -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_PASSWORD=$SPLUNK_PASSWORD" $SPLUNK_IMAGE | ||
curl -k -u admin:$SPLUNK_PASSWORD -X POST http://localhost:$SPLUNK_PORT/services/admin/token-auth/tokens_auth -d disabled=false | ||
TOKEN_OUTPUT=$(curl -k -u admin:$SPLUNK_PASSWORD -X POST http://localhost:$SPLUNK_PORT/services/authorization/tokens?output_mode=json) | ||
echo "SPLUNK_TOKEN=$(echo $TOKEN_OUTPUT | jq '.entry[0].content.token')" >> $GITHUB_ENV | ||
- name: build | ||
run: sudo make build | ||
- name: test-e2e | ||
run: SPLUNK_TOKEN=${{ env.SPLUNK_TOKEN }} sudo make test-e2e-for-splunk # containerd interaction requires sudo | ||
go-mod-tidy-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
# TODO: Use `go mod tidy --check` after https://github.com/golang/go/issues/27005 is fixed. | ||
- run: go mod tidy | ||
- run: git diff --exit-code | ||
mdlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: avto-dev/markdown-lint@v1 | ||
with: | ||
args: '**/*.md' | ||