chore: Web UI enhancement #36
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
--- | |
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | |
# @see https://docs.github.com/en/actions/guides/creating-postgresql-service-containers | |
# @see https://github.com/actions/virtual-environments | |
# @see https://www.postgresql.jp/document/11/html/app-pgrestore.html | |
name: Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
unit: | |
name: Unit | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
check-latest: true | |
cache: true | |
- name: Download modules | |
run: go mod download | |
- name: Lint | |
run: make lint | |
- name: Test | |
run: make test | |
feature: | |
name: Feature | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
postgres: | |
- 10-alpine | |
- 11-alpine | |
- 12-alpine | |
- 13-alpine | |
- 14-alpine | |
- 15-alpine | |
- 16-alpine | |
services: | |
postgres: | |
image: postgres:${{ matrix.postgres }} | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_INITDB_ARGS: '--auth-host=scram-sha-256' | |
env: | |
PGHOST: 127.0.0.1 | |
PGPORT: 5432 | |
PGDATABASE: postgres | |
steps: | |
- name: Install PostgreSQL clients | |
run: sudo apt update && sudo apt install -y --no-install-recommends postgresql-client | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
check-latest: true | |
cache: true | |
- name: Download modules | |
run: go mod download | |
- name: Build | |
run: make term | |
- name: Create role for test | |
run: | | |
echo -n "CREATE ROLE test WITH LOGIN PASSWORD " >> $SQL_FILE_PATH | |
echo -n "'" >> $SQL_FILE_PATH | |
./cmd/term/encrypt test | tr -d '\n' >> $SQL_FILE_PATH | |
echo "';" >> $SQL_FILE_PATH | |
cat $SQL_FILE_PATH | tee /dev/stderr | psql | |
env: | |
SQL_FILE_PATH: /tmp/create_role.sql | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
- name: Check roles out | |
run: psql -c 'SELECT usename, passwd FROM pg_catalog.pg_shadow' | |
env: | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
- name: Test login success | |
run: psql -c 'SELECT user' | |
env: | |
PGUSER: test | |
PGPASSWORD: test | |
- name: Test login fail | |
run: psql -c 'SELECT user' || echo 'fail ok' | |
env: | |
PGUSER: test | |
PGPASSWORD: wrong |