Skip to content

Commit

Permalink
chore: add test action (#19)
Browse files Browse the repository at this point in the history
* chore: add test action

* change to postgres

* update migration

* update action

* update action

* update action
  • Loading branch information
hwbrzzl authored Jun 26, 2024
1 parent 6fd9bbc commit a9edfdd
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
APP_NAME=Goravel
APP_ENV=local
APP_KEY=h20Gmg7UIuUDD66gfUSUjIkPLU8KLqMK
APP_DEBUG=true
APP_URL=http://localhost
APP_HOST=127.0.0.1
APP_PORT=3000

GRPC_HOST=127.0.0.1
GRPC_PORT=3001

JWT_SECRET=L9qknFZyWHDSVXXe1TjUsR7XQsxkbb8B

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=postgres
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=goravel
DB_USERNAME=goravel
DB_PASSWORD=goravel

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=
REDIS_PORT=6379

MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test
on:
push:
branches:
- master
pull_request:
jobs:
ubuntu:
strategy:
matrix:
go: [ "1.21", "1.22" ]
runs-on: ubuntu-latest
steps:
- name: Set up PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql version: '11'
postgresql db: 'goravel'
postgresql user: 'goravel'
postgresql password: 'goravel'
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Go mod cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: go mod tidy
- name: Run migrate
run: go run . artisan migrate
- name: Run tests
run: go test -timeout 1h ./...
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.idea
.DS_Store
.env
storage/framework
2 changes: 1 addition & 1 deletion config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
"prefix": "",
"singular": false, // Table name is singular
},
"postgresql": map[string]any{
"postgres": map[string]any{
"driver": "postgresql",
"host": config.Env("DB_HOST", "127.0.0.1"),
"port": config.Env("DB_PORT", 5432),
Expand Down
17 changes: 7 additions & 10 deletions database/migrations/20230219170634_create_users_table.up.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
CREATE TABLE users (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
name varchar(191) DEFAULT '' NOT NULL,
avatar varchar(191) DEFAULT '' NOT NULL,
created_at datetime(3) NOT NULL,
updated_at datetime(3) NOT NULL,
deleted_at datetime(3) DEFAULT NULL,
PRIMARY KEY (id),
KEY idx_users_created_at (created_at),
KEY idx_users_updated_at (updated_at)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
id SERIAL PRIMARY KEY NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
avatar varchar(255) DEFAULT '' NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL,
deleted_at timestamp DEFAULT NULL
);

0 comments on commit a9edfdd

Please sign in to comment.