Skip to content

Commit 659e232

Browse files
authored
Merge pull request #1425 from traPtitech/conf/atlas_community
atlasのcommunity editionを使ってlintする
2 parents 49f54d1 + cf143c4 commit 659e232

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ jobs:
9595
with:
9696
fetch-depth: 0
9797

98-
- name: Setup Atlas
99-
uses: ariga/setup-atlas@4240bd74ba9f13319a21de2b6e497f2b6d184d76 # v0
98+
- name: Setup Atlas community edition
99+
run: |
100+
curl -sSf https://atlasgo.sh | sh -s -- --community --yes
101+
shell: bash
100102

101103
- name: Atlas Lint
102104
run: |
103105
set +e
104106
105-
LINT_OUTPUT="$(atlas migrate lint --env ci 2>&1)"
107+
LINT_OUTPUT="$(atlas migrate lint --config file://atlas.ci.hcl --env ci 2>&1)"
106108
LINT_EXIT_CODE=$?
107109
108110
if [ "$LINT_EXIT_CODE" -eq 0 ]; then

Taskfile.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3"
1+
version: '3'
22

33
includes:
44
os:
@@ -92,19 +92,14 @@ tasks:
9292
migrate:new:
9393
cmds:
9494
- task: os:migrate:new
95-
desc: "マイグレーションファイルを生成する。名前を指定できる。 (task migrate:new -- <migration_name>)"
95+
desc: 'マイグレーションファイルを生成する。名前を指定できる。 (task migrate:new -- <migration_name>)'
9696

9797
migrate:down:
9898
cmds:
9999
- task: os:migrate:down
100-
desc: "マイグレーションを1つ戻して、マイグレーションファイルを削除する"
100+
desc: 'マイグレーションを1つ戻して、マイグレーションファイルを削除する'
101101

102102
migrate:down:down-only:
103103
cmds:
104104
- task: os:migrate:down:down-only
105-
desc: "マイグレーションを1つ戻すが、マイグレーションファイルは削除しない"
106-
107-
migrate:lint:
108-
cmds:
109-
- task: os:migrate:lint
110-
desc: "マイグレーションの Lint を実行する"
105+
desc: 'マイグレーションを1つ戻すが、マイグレーションファイルは削除しない'

atlas.ci.hcl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
lint {
2+
non_linear {
3+
error = true
4+
}
5+
}
6+
7+
env "local" {
8+
dev = "docker://mariadb/10.7/trap_collection"
9+
10+
migration {
11+
dir = "file://migrations"
12+
}
13+
14+
lint {
15+
git {
16+
base = "origin/main"
17+
}
18+
}
19+
}
20+
21+
env "ci" {
22+
dev = "mysql://root:pass@localhost:3306/trap_collection"
23+
24+
lint {
25+
git {
26+
base = "origin/main"
27+
}
28+
}
29+
}

docs/migration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ task migrate:down:down-only
7070
## マイグレーションの Lint
7171

7272
Atlas の Lint 機能を使って、マイグレーションファイルのチェックを行うことができます。
73+
ただし、通常の Atlas CLI の free plan では、Lint 機能を使うことができません。必要であれば community edition をインストールして使ってください。
74+
GitHub Actions の CI では community edition を使って Lint を実行しています。
7375
以下のコマンドを実行してください。
7476

7577
```bash
76-
task migrate:lint
78+
atlas migrate lint --config file://atlas.ci.hcl --env local
7779
```
7880

7981
このコマンドでは、main ブランチと比較してマイグレーションが正しいかをチェックします。

task/Taskfile_unix.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,3 @@ tasks:
101101
dir: ../
102102
cmds:
103103
- atlas migrate down --env local
104-
105-
migrate:lint:
106-
dir: ../
107-
cmds:
108-
- atlas migrate lint --env local --git-base main

task/Taskfile_windows.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3"
1+
version: '3'
22

33
tasks:
44
download:
@@ -101,8 +101,3 @@ tasks:
101101
dir: ..\
102102
cmds:
103103
- atlas migrate down --env local
104-
105-
migrate:lint:
106-
dir: ..\
107-
cmds:
108-
- atlas migrate lint --env local --git-base main

0 commit comments

Comments
 (0)