Fix parameters camelCase support in loadEnvVars for environment varia… #44
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: Test GatewayD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
paths-ignore: | |
- "README.md" | |
- "LICENSE" | |
- "CONTRIBUTING.md" | |
- "CODE_OF_CONDUCT.md" | |
- ".gitignore" | |
- ".gitattributes" | |
pull_request: | |
paths-ignore: | |
- "README.md" | |
- "LICENSE" | |
- "CONTRIBUTING.md" | |
- "CODE_OF_CONDUCT.md" | |
- ".gitignore" | |
- ".gitattributes" | |
jobs: | |
test: | |
name: Test GatewayD | |
runs-on: ubuntu-latest | |
# Timeout after 5 minutes, to avoid hanging tests | |
timeout-minutes: 5 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_HOST: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
postgres2: | |
image: postgres | |
env: | |
POSTGRES_HOST: postgres2 | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5433:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Go 🧑💻 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Lint code with golangci-lint 🚨 | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: "v1.59.1" | |
skip-pkg-cache: true | |
install-mode: "goinstall" | |
- name: Lint Bash script with shellcheck 🚨 | |
uses: ludeeus/action-shellcheck@master | |
- name: Lint Dockerfile with hadolint 🚨 | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
- name: Run Go tests 🔬 | |
run: go test -p 1 -cover -covermode atomic -coverprofile=profile.cov -v ./... | |
env: | |
GITHUB_AUTH_TOKEN: ${{ secrets.INTEGRATION }} | |
- name: Report coverage to coveralls 📈 | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: profile.cov | |
ignore: "api/v1/*,usagereport/*" | |
test-plugin: | |
name: Test GatewayD Plugins | |
runs-on: ubuntu-latest | |
needs: test | |
timeout-minutes: 5 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_HOST: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Go 🧑💻 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Checkout test plugin 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
repository: gatewayd-io/plugin-template-go | |
path: plugin-template-go | |
- name: Build template plugin 🏗️ | |
run: | | |
# Build GatewayD | |
make build-dev | |
# Build template plugin | |
cd plugin-template-go && make build && cp plugin-template-go ../ptg && cd .. | |
export SHA256SUM=$(sha256sum ptg | awk '{print $1}') | |
cat <<EOF > gatewayd_plugins.yaml | |
compatibilityPolicy: "strict" | |
metricsMergerPeriod: 1s | |
healthCheckPeriod: 1s | |
reloadOnCrash: true | |
timeout: 30s | |
plugins: | |
- name: plugin-template-go | |
enabled: True | |
url: github.com/gatewayd-io/plugin-template-go | |
localPath: ./ptg | |
args: ["--log-level", "debug"] | |
env: | |
- MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN | |
- MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872 | |
checksum: ${SHA256SUM} | |
EOF | |
- name: Run GatewayD with template plugin 🚀 | |
run: ./gatewayd run -c testdata/gatewayd_tls.yaml & | |
- name: Install PSQL 🧑💻 | |
run: | | |
sudo apt-get update | |
sudo apt-get install --yes --no-install-recommends postgresql-client | |
- name: Run a test with PSQL over plaintext connection 🧪 | |
run: | | |
psql ${PGURL} -c "CREATE TABLE test_table (id serial PRIMARY KEY, name varchar(255));" | grep CREATE || exit 1 | |
psql ${PGURL} -c "INSERT INTO test_table (name) VALUES ('test');" | grep INSERT || exit 1 | |
psql ${PGURL} -c "SELECT * FROM test_table;" | grep test || exit 1 | |
psql ${PGURL} -c "DROP TABLE test_table;" | grep DROP || exit 1 | |
env: | |
PGURL: postgres://postgres:postgres@localhost:15432/postgres?sslmode=disable | |
- name: Run a test with PSQL over TLS connection 🧪 | |
run: | | |
psql ${PGURL_TLS} -c "CREATE TABLE test_table (id serial PRIMARY KEY, name varchar(255));" | grep CREATE || exit 1 | |
psql ${PGURL_TLS} -c "INSERT INTO test_table (name) VALUES ('test');" | grep INSERT || exit 1 | |
psql ${PGURL_TLS} -c "SELECT * FROM test_table;" | grep test || exit 1 | |
psql ${PGURL_TLS} -c "DROP TABLE test_table;" | grep DROP || exit 1 | |
env: | |
PGURL_TLS: postgres://postgres:postgres@localhost:15432/postgres?sslmode=require |