Implement the new JSON binary protocol #713
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: Test GatewayD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
test: | |
name: Test GatewayD | |
runs-on: ubuntu-latest | |
# Timeout after 3 minutes, to avoid hanging tests | |
timeout-minutes: 3 | |
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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Go 🧑💻 | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.20" | |
- run: | | |
git config --global url."https://mostafa:${TOKEN}@github.com/".insteadOf "https://github.com" | |
go mod tidy | |
env: | |
TOKEN: ${{ secrets.GH_SDK_TOKEN }} | |
GOPRIVATE: github.com/gatewayd-io/gatewayd-* | |
- name: Lint code issues 🚨 | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
skip-pkg-cache: true | |
- name: Run Go tests 🔬 | |
run: go test -cover -covermode atomic -coverprofile=profile.cov -v ./... | |
# Enable coverage reporting | |
# - name: Report coverage to coveralls 📈 | |
# uses: shogo82148/actions-goveralls@v1 | |
# with: | |
# path-to-profile: profile.cov | |
test-plugin: | |
name: Test GatewayD Plugins | |
runs-on: ubuntu-latest | |
needs: test | |
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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Go 🧑💻 | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.20" | |
- run: | | |
git config --global url."https://mostafa:${TOKEN}@github.com/".insteadOf "https://github.com" | |
go mod tidy | |
env: | |
TOKEN: ${{ secrets.GH_SDK_TOKEN }} | |
GOPRIVATE: github.com/gatewayd-io/gatewayd-* | |
- name: Checkout test plugin 🛎️ | |
uses: actions/checkout@v3 | |
with: | |
repository: gatewayd-io/plugin-template-go | |
path: plugin-template-go | |
token: ${{ secrets.GH_PLUGIN_TOKEN }} | |
- 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 | |
verificationPolicy: "passdown" | |
compatibilityPolicy: "strict" | |
acceptancePolicy: "accept" | |
terminationPolicy: "stop" | |
metricsMergerPeriod: 1s | |
healthCheckPeriod: 1s | |
reloadOnCrash: true | |
timeout: 30s | |
plugins: | |
- name: plugin-template-go | |
enabled: True | |
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: | | |
sed -i 's/level: "info"/level: "debug"/g' gatewayd.yaml # Enable debug logs | |
./gatewayd run & | |
- name: Run a test with PSQL 🧪 | |
run: | | |
sudo apt-get update | |
sudo apt-get install --yes --no-install-recommends postgresql-client | |
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 | |
env: | |
PGURL: postgres://postgres:postgres@localhost:15432/postgres |