Skip to content

Commit

Permalink
Merge ec9650d into 1a0ea43
Browse files Browse the repository at this point in the history
  • Loading branch information
wheatandcat committed Oct 30, 2021
2 parents 1a0ea43 + ec9650d commit 6ec1967
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 352 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/scenarigo.yml
@@ -0,0 +1,61 @@
name: e2e test
on: [push]
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
SERVICE_ACCOUNT_JSON: ${{ secrets.REVIEW_SERVICE_ACCOUNT_JSON }}
GCP_SERVICE_ACCOUNT_JSON: ${{ secrets.REVIEW_GCP_SERVICE_ACCOUNT_JSON }}
APP_LOCAL_EMV: ${{ secrets.APP_LOCAL_EMV }}
ENVENB_GO: ${{ secrets.ENVENB_GO }}
AUTH_CONFIG: ${{ secrets.AUTH_CONFIG }}
jobs:
e2e:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create serviceAccount.json file
run: echo $SERVICE_ACCOUNT_JSON | base64 --decode -i > ./serviceAccount.json
- name: Create gcpServiceAccount.json file
run: echo $GCP_SERVICE_ACCOUNT_JSON | base64 --decode -i > ./gcpServiceAccount.json
- name: Create .env file
run: echo $APP_LOCAL_EMV | base64 --decode -i > ./.env
- name: Create envenb.go file
run: echo $ENVENB_GO | base64 --decode -i > ./envenb.go
- name: Create e2e/.env file
run: echo $AUTH_CONFIG | base64 --decode -i > ./e2e/.env
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
- run: go version
- name: cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-memoir-backend-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-memoir-backend-
- name: Run server
run: make ci_setup_server
- name: create auth token file
run: make create_login_yaml
working-directory: ./e2e
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: setup gcloud
uses: google-github-actions/setup-gcloud@master
with:
version: "latest"
- name: setup firestore emulator
run: |
gcloud components install beta --quiet
gcloud components install cloud-firestore-emulator --quiet
- name: setup e2e
run: |
gcloud beta emulators firestore start --host-port localhost:3600 &
go install github.com/zoncoen/scenarigo/cmd/scenarigo@v0.8.1
working-directory: ./e2e
- name: run e2e
run: make scenarigo
working-directory: ./e2e
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15'
go-version: '^1.16'
- run: go version
- name: cache
uses: actions/cache@v2
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Expand Up @@ -17,4 +17,10 @@ node_modules
tmp/
.env
coverage.out
cover.html
cover.html
e2e/.env
e2e/login.yaml
e2e/serviceAccount.json
ui-debug.log
firestore-debug.log
envenb.go
2 changes: 1 addition & 1 deletion .go-version
@@ -1 +1 @@
1.15.5
1.16.5
5 changes: 4 additions & 1 deletion Makefile
@@ -1,4 +1,7 @@
.PHONY: moqgen
moqgen:
@-rm -f ./repository/moqs/*.go
go generate ./repository/...
go generate ./repository/...
.PHONY: ci_setup_server
ci_setup_server:
FIRESTORE_EMULATOR_HOST=localhost:3600 go run app.go &
64 changes: 47 additions & 17 deletions README.md
Expand Up @@ -23,55 +23,66 @@ $ yarn graphql-markdown http://localhost:8080/query > schema.md

## GraphQLスキーマ更新

```
```:zsh
$ go run github.com/99designs/gqlgen generate
```

## テスト

## ユニットテスト

### 実行
moqを生成
```
```:zsh
$ make moqgen
```

テストを実行
```
```:zsh
$ go test -race ./...
```

### カバレッジ表示

### インストール
```
```:zsh
$ brew install k1LoW/tap/octocov
```

### 実行
```
```:zsh
$ go test ./... -coverprofile=coverage.out
$ octocov
```

### 各ファイルカバレッジ確認
```
```:zsh
$ octocov ls-files
```

```
```:zsh
$ octocov view graph/invite.go
```

## 手動デプロイ
## E2Eテスト

```:zsh
$ FIRESTORE_EMULATOR_HOST=localhost:3600 air
```

```:zsh
$ cd e2e
$ make create_loggin_yaml
$ make local_scenarigo
```

## 手動デプロイ

```:zsh
$ gcloud app deploy
```

## 本番デプロイ

```
```:zsh
$ git checkout main
$ git pull --ff-only origin main
$ git tag -a v1.0.0 -m 'リリース内容'
Expand All @@ -80,31 +91,50 @@ $ git push origin v1.0.0

## CI環境

### レビュー環境
### Firebase トークン

```:zsh
$ firebase login:ci
```
### レビュー環境

```:zsh
$ base64 -i serviceAccount.review.json | pbcopy
```

```
```:zsh
$ base64 -i gcpServiceAccount.review.json | pbcopy
```

```
```:zsh
$ base64 -i app.yaml | pbcopy
```

### 本番環境
### E2E

```:zsh
$ base64 -i .env | pbcopy
```
$ base64 -i serviceAccount.production.json | pbcopy

```:zsh
$ base64 -i envenb.go | pbcopy
```

```:zsh
$ base64 -i e2e/.env | pbcopy
```
$ base64 -i gcpServiceAccount.production.json | pbcopy

### 本番環境

```:zsh
$ base64 -i serviceAccount.production.json | pbcopy
```

```:zsh
$ base64 -i gcpServiceAccount.production.json | pbcopy
```

```:zsh
$ base64 -i app.production.yaml | pbcopy
```

9 changes: 9 additions & 0 deletions e2e/Makefile
@@ -0,0 +1,9 @@
.PHONY: create_loggin_yaml
create_login_yaml:
go run script/main.go
.PHONY: scenarigo
scenarigo:
HOST=localhost:8080 scenarigo run
.PHONY: local_scenarigo
local_scenarigo:
npx firebase --config ./simulator/firebase.json emulators:exec 'HOST=localhost:8080 scenarigo run'
73 changes: 73 additions & 0 deletions e2e/item.yaml
@@ -0,0 +1,73 @@

title: アイテム
steps:
- title: login
include: './login.yaml'
bind:
vars:
userToken: "{{vars.userToken}}"
- title: アイテムを作成する①
bind:
vars:
itemID: "{{response.data.createItem.id}}"
protocol: http
request:
method: POST
url: "http://{{env.HOST}}/query"
header:
Authorization: "Bearer {{vars.userToken}}"
Content-Type: application/json
body:
query: |-
mutation CreateItem($input: NewItem!) {
createItem(input: $input) {
id
title
date
categoryID
like
dislike
createdAt
updatedAt
}
}
variables:
input:
title: 散歩に行った
categoryID: 1
date: 2021-01-01T00:00:00+09:00
like: true
dislike: false

- title: アイテムを取得する
protocol: http
request:
method: POST
url: "http://{{env.HOST}}/query"
header:
Authorization: "Bearer {{vars.userToken}}"
Content-Type: application/json
body:
query: |-
query Item($id: ID!) {
item(id: $id) {
id
title
categoryID
date
like
dislike
}
}
variables:
id: "{{vars.itemID}}"
expect:
body:
data:
item:
id: "{{vars.itemID}}"
title: 散歩に行った
categoryID: 1
date: 2021-01-01T00:00:00+09:00
like: true
dislike: false
5 changes: 5 additions & 0 deletions e2e/scenarigo.yaml
@@ -0,0 +1,5 @@
schemaVersion: config/v1

scenarios:
- user.yaml
- item.yaml

0 comments on commit 6ec1967

Please sign in to comment.