Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ariga/atlas-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.8
Choose a base ref
...
head repository: ariga/atlas-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 38,692 additions and 40,042 deletions.
  1. +3 −1 .eslintignore
  2. +3 −52 .eslintrc.json
  3. +130 −0 .github/workflows/cd.yaml
  4. +458 −0 .github/workflows/ci-go.yaml
  5. +0 −45 .github/workflows/ci.yaml
  6. +7 −1 .gitignore
  7. +7 −0 .golangci.yml
  8. +3 −3 .prettierrc.json
  9. +16 −0 Dockerfile
  10. +436 −73 README.md
  11. +0 −713 __tests__/atlas.test.ts
  12. +0 −244 __tests__/cloud.test.ts
  13. +0 −113 __tests__/env.ts
  14. +0 −56 __tests__/github.test.ts
  15. +0 −90 __tests__/input.test.ts
  16. +0 −122 __tests__/reporting.test.ts
  17. +0 −3 __tests__/testdata/git-repo/base/20220318104614_initial.sql
  18. +0 −2 __tests__/testdata/git-repo/base/atlas.sum
  19. +0 −3 __tests__/testdata/git-repo/changes/20220318104614_initial.sql
  20. +0 −2 __tests__/testdata/git-repo/changes/20220728131023.sql
  21. +0 −3 __tests__/testdata/git-repo/changes/atlas.sum
  22. +0 −1 __tests__/testdata/golang-migrate/1_initial.down.sql
  23. +0 −4 __tests__/testdata/golang-migrate/1_initial.up.sql
  24. +0 −1 __tests__/testdata/golang-migrate/2_second_migration.down.sql
  25. +0 −1 __tests__/testdata/golang-migrate/2_second_migration.up.sql
  26. +0 −533 __tests__/testdata/pr-context.json
  27. +0 −3 __tests__/testdata/runs/base.expected.txt
  28. +0 −88 __tests__/testdata/runs/base.txt
  29. +0 −3 __tests__/testdata/runs/checksum.expected.txt
  30. +0 −34 __tests__/testdata/runs/checksum.txt
  31. +0 −8 __tests__/testdata/runs/cloudreports.expected.txt
  32. +0 −52 __tests__/testdata/runs/cloudreports.txt
  33. +0 −3 __tests__/testdata/runs/cloudurl.expected.txt
  34. +0 −88 __tests__/testdata/runs/cloudurl.txt
  35. +0 −78 __tests__/testdata/runs/destructive.txt
  36. +0 −5 __tests__/testdata/runs/error.expected.txt
  37. +0 −78 __tests__/testdata/runs/error.txt
  38. +0 −3 __tests__/testdata/runs/sqlerr.expected.txt
  39. +0 −38 __tests__/testdata/runs/sqlerr.txt
  40. +0 −1 __tests__/testdata/sqlite-broken-file/20220318104614_initial.sql
  41. +0 −2 __tests__/testdata/sqlite-with-diagnostics/20220823074833_init.sql
  42. +0 −2 __tests__/testdata/sqlite-with-diagnostics/20220823074933_add_name.sql
  43. +0 −2 __tests__/testdata/sqlite-with-diagnostics/20220823075011_uniq_name.sql
  44. +0 −4 __tests__/testdata/sqlite-with-diagnostics/atlas.sum
  45. +0 −3 __tests__/testdata/sqlite-wrong-sum/20220318104614_initial.sql
  46. +0 −2 __tests__/testdata/sqlite-wrong-sum/atlas.sum
  47. +0 −36 __tests__/vercheck.test.ts
  48. +3 −0 action.yml
  49. +1,315 −0 atlasaction/action.go
  50. +2,313 −0 atlasaction/action_test.go
  51. +349 −0 atlasaction/bitbucket.go
  52. +52 −0 atlasaction/bitbucket_test.go
  53. +120 −0 atlasaction/circleci_action.go
  54. +130 −0 atlasaction/circleci_action_test.go
  55. +169 −0 atlasaction/cloud/client.go
  56. +33 −0 atlasaction/cloud/client_test.go
  57. +42 −0 atlasaction/comments/bitbucket.md
  58. +20 −0 atlasaction/comments/commons.md
  59. +44 −0 atlasaction/comments/lint-report.tmpl
  60. +75 −0 atlasaction/comments/migrate-apply.tmpl
  61. +22 −0 atlasaction/comments/migrate-lint.tmpl
  62. +71 −0 atlasaction/comments/schema-apply.tmpl
  63. +37 −0 atlasaction/comments/schema-plan.tmpl
  64. +12 −0 atlasaction/comments/suggestion.tmpl
  65. +333 −0 atlasaction/gh_action.go
  66. +141 −0 atlasaction/gitlab_ci.go
  67. +121 −0 atlasaction/gitlab_ci_test.go
  68. +49 −0 atlasaction/mock-atlas.sh
  69. +61 −0 atlasaction/testdata/bitbucket/schema-push.txtar
  70. +14 −0 atlasaction/testdata/broken/20240619073211_init.sql
  71. +5 −0 atlasaction/testdata/broken/20240619073319_broken_migration.sql
  72. +3 −0 atlasaction/testdata/broken/atlas.sum
  73. +29 −0 atlasaction/testdata/circleci/migrate-lint.txtar
  74. +7 −0 atlasaction/testdata/config/atlas.hcl
  75. +1 −0 atlasaction/testdata/diagnostics/20230922132634_init.sql
  76. +1 −0 atlasaction/testdata/diagnostics/20231016114135_add_not_null.sql
  77. +3 −0 atlasaction/testdata/diagnostics/atlas.sum
  78. +1 −0 atlasaction/testdata/down/1.sql
  79. +1 −0 atlasaction/testdata/down/2.sql
  80. +1 −0 atlasaction/testdata/down/3.sql
  81. +4 −0 atlasaction/testdata/down/atlas.sum
  82. +1 −0 atlasaction/testdata/drop_column/20240626085256_init.sql
  83. +2 −0 atlasaction/testdata/drop_column/20240626085324_drop_col.sql
  84. +3 −0 atlasaction/testdata/drop_column/atlas.sum
  85. +23 −0 atlasaction/testdata/github/migrate-lint.txtar
  86. +27 −0 atlasaction/testdata/github/migrate-test.txtar
  87. +157 −0 atlasaction/testdata/github/schema-apply-envs.txtar
  88. +61 −0 atlasaction/testdata/github/schema-apply-lint.txtar
  89. +52 −0 atlasaction/testdata/github/schema-push.txtar
  90. +26 −0 atlasaction/testdata/github/schema-test.txtar
  91. +81 −0 atlasaction/testdata/gitlab/schema-plan-approve.txtar
  92. +164 −0 atlasaction/testdata/gitlab/schema-plan.txtar
  93. +19 −0 atlasaction/testdata/migrations.test.hcl
  94. +1 −0 atlasaction/testdata/migrations/20230922132634_init.sql
  95. +2 −0 atlasaction/testdata/migrations/atlas.sum
  96. +1 −0 atlasaction/testdata/migrations_destructive/20230922132634_init.sql
  97. +1 −0 atlasaction/testdata/migrations_destructive/20230925192914.sql
  98. +3 −0 atlasaction/testdata/migrations_destructive/atlas.sum
  99. +10 −0 atlasaction/testdata/schema-apply/legacy/atlas.hcl
  100. 0 atlasaction/testdata/schema-apply/legacy/local.db
  101. +8 −0 atlasaction/testdata/schema-apply/legacy/schema-1.lt.hcl
  102. +16 −0 atlasaction/testdata/schema-apply/legacy/schema-2.lt.hcl
  103. +8 −0 atlasaction/testdata/schema-apply/lint-review/atlas.hcl
  104. BIN atlasaction/testdata/schema-apply/lint-review/local.db
  105. +22 −0 atlasaction/testdata/schema-apply/lint-review/schema.lt.hcl
  106. +8 −0 atlasaction/testdata/schema-apply/local-plan/20240910173744.plan.hcl
  107. +5 −0 atlasaction/testdata/schema-apply/local-plan/atlas.hcl
  108. BIN atlasaction/testdata/schema-apply/local-plan/local.db
  109. +32 −0 atlasaction/testdata/schema-apply/local-plan/schema.lt.hcl
  110. +8 −0 atlasaction/testdata/schema-apply/multiple-envs/20240910173744.plan.hcl
  111. +7 −0 atlasaction/testdata/schema-apply/multiple-envs/atlas.hcl
  112. BIN atlasaction/testdata/schema-apply/multiple-envs/local-bu.db
  113. BIN atlasaction/testdata/schema-apply/multiple-envs/local-pi.db
  114. BIN atlasaction/testdata/schema-apply/multiple-envs/local-su.db
  115. +32 −0 atlasaction/testdata/schema-apply/multiple-envs/schema.lt.hcl
  116. +5 −0 atlasaction/testdata/schema-apply/on-the-fly/atlas.hcl
  117. BIN atlasaction/testdata/schema-apply/on-the-fly/local.db
  118. +32 −0 atlasaction/testdata/schema-apply/on-the-fly/schema.lt.hcl
  119. +16 −0 atlasaction/testdata/schema-apply/remote-repo/atlas.hcl
  120. BIN atlasaction/testdata/schema-apply/remote-repo/local.db
  121. +32 −0 atlasaction/testdata/schema-apply/remote-repo/schema.lt.hcl
  122. +8 −0 atlasaction/testdata/schema.hcl
  123. +13 −0 atlasaction/testdata/schema.test.hcl
  124. +199 −0 atlasaction/testdata/templates/migrate-apply.txtar
  125. +71 −0 atlasaction/testdata/templates/migrate-lint-md.txtar
  126. +149 −0 atlasaction/testdata/templates/migrate-lint.txtar
  127. +92 −0 atlasaction/testdata/templates/schema-plan-md.txtar
  128. +25 −0 cmd/atlas-action/main.go
  129. +0 −13 codegen.ts
  130. +18,799 −18,745 dist/index.js
  131. +1 −1 dist/index.js.map
  132. +0 −1,080 dist/licenses.txt
  133. +137 −0 doc/typescript-action.md
  134. +37 −0 go.mod
  135. +93 −0 go.sum
  136. +388 −0 internal/bitbucket/bitbucket.go
  137. +65 −0 internal/cmdapi/cmdapi.go
  138. +29 −0 internal/cmdapi/cmdapi_test.go
  139. +351 −0 internal/github/github.go
  140. +161 −0 internal/gitlab/gitlab.go
  141. +0 −10 jest.config.js
  142. +59 −0 migrate/apply/action.yml
  143. +1 −0 migrate/apply/index.js
  144. +68 −0 migrate/down/action.yml
  145. +1 −0 migrate/down/index.js
  146. +48 −0 migrate/lint/action.yml
  147. +1 −0 migrate/lint/index.js
  148. +49 −0 migrate/push/action.yml
  149. +1 −0 migrate/push/index.js
  150. +48 −0 migrate/test/action.yml
  151. +1 −0 migrate/test/index.js
  152. +36 −0 monitor/schema/action.yml
  153. +4 −0 monitor/schema/atlas.hcl
  154. +1 −0 monitor/schema/index.js
  155. +2,484 −16,612 package-lock.json
  156. +8 −28 package.json
  157. +61 −0 schema/apply/action.yml
  158. +1 −0 schema/apply/index.js
  159. +57 −0 schema/plan/action.yml
  160. +55 −0 schema/plan/approve/action.yml
  161. +1 −0 schema/plan/approve/index.js
  162. +1 −0 schema/plan/index.js
  163. +66 −0 schema/push/action.yml
  164. +1 −0 schema/push/index.js
  165. +43 −0 schema/test/action.yml
  166. +1 −0 schema/test/index.js
  167. +10 −0 scripts/setup-atlas.sh
  168. +7,407 −0 shim/dist/index.js
  169. +50 −0 shim/index.js
  170. +0 −149 src/atlas.ts
  171. +0 −154 src/cloud.ts
  172. +0 −255 src/github.ts
  173. +0 −111 src/input.ts
  174. +0 −70 src/main.ts
  175. +0 −76 src/schema.graphql
  176. +0 −28 src/vercheck.ts
  177. +0 −23 tsconfig.json
  178. +0 −88 types/types.ts
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dist/
lib/
node_modules/
jest.config.js
migrate/*
schema/*
jest.config.js
55 changes: 3 additions & 52 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
{
"plugins": ["jest", "@typescript-eslint", "unused-imports"],
"plugins": ["unused-imports"],
"extends": [
// ESLint's inbuilt "recommended" config - it turns on a small, sensible set of rules which lint for well-known best-practices.
"eslint:recommended",
// "typescript-eslint/recommended" config - it's just like eslint:recommended, except it only turns on rules from our TypeScript-specific plugin.
"plugin:@typescript-eslint/recommended",
// eslint-plugin-import config - sorts imports properly - defaults & TS support
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
],
// This allows ESLint to understand TypeScript syntax.
// This is required, or else ESLint will throw errors as it tries to parse TypeScript code as if it were regular JavaScript.
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
@@ -23,54 +17,11 @@
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "no-public"
}
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
"semi": "off"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
"es6": true
}
}
130 changes: 130 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build and Upload to CDN
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit SHA'
required: false
version:
description: 'Version (should follow semver v1.2.3)'
required: false
push:
branches:
- master
tags:
- 'v*'
jobs:
test:
uses: ./.github/workflows/ci-go.yaml
secrets: inherit
build:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
env:
REGISTRY: "docker.io"
IMAGE_NAME: "arigaio/atlas-action"
DOCKERHUB_USERNAME: arigaio
steps:
- name: Checkout code
uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.inputs.commit || 'master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub (${{ env.REGISTRY }})
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.RELEASE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.RELEASE_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Setup Go Environment
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Install Atlas
uses: ariga/setup-atlas@v0
- name: Set BINARY_NAME
id: set_binary_name
env:
VERSION: ${{ github.event.inputs.version || github.ref_name }}
run: |
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BINARY_NAME=atlas-action-$VERSION" >> $GITHUB_ENV
- name: Compile Go Binary
run: |
COMMIT=$(git rev-parse --short HEAD)
go build -o atlas-action -ldflags "-s -w -X main.version=$VERSION -X main.commit=$COMMIT" ./cmd/atlas-action
OUTPUT=$(./atlas-action --version)
if [[ $(echo $OUTPUT | grep -i "^atlas-action version $VERSION-$COMMIT") ]]; then
echo "Version=$OUTPUT"
else
echo "unexpected output: $OUTPUT, expected: atlas-action version $VERSION-$COMMIT"
exit 1
fi
env:
CGO_ENABLED: 0
- name: Upload binary to S3
run: |
aws s3 cp ./atlas-action s3://release.ariga.io/atlas-action/$BINARY_NAME
env:
AWS_REGION: us-east-1
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: true
# Run end-to-end test on the published binary.
e2e-test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_TOKEN }}
- name: Run Migrate Lint
env:
GITHUB_TOKEN: ${{ github.token }}
uses: jenseng/dynamic-uses@v1
with:
uses: ariga/atlas-action/migrate/lint@${{ github.event.inputs.version || 'v1' }}
with: '{
"dir": "file://atlasaction/testdata/migrations",
"dev-url": "sqlite://dev?mode=memory",
"dir-name": "test-dir-sqlite"
}'
- name: Run Migrate Push
uses: jenseng/dynamic-uses@v1
with:
uses: ariga/atlas-action/migrate/push@${{ github.event.inputs.version || 'v1' }}
with: '{
"dir": "file://atlasaction/testdata/migrations",
"dev-url": "sqlite://dev?mode=memory",
"dir-name": "test-dir-sqlite"
}'
Loading