Skip to content

action/migrate-lint: added a go-bases lint implementation #110

action/migrate-lint: added a go-bases lint implementation

action/migrate-lint: added a go-bases lint implementation #110

Workflow file for this run

name: Go Continuous Integration
on:
push:
branches:
- master
pull_request:
workflow_call:
jobs:
shim:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'npm'
- name: Install
run: |
npm i
npm i -g @vercel/ncc
npm run shim
- name: verify no git diff
run: |
status=$(git status --porcelain)
if [ -n "$status" ]; then
echo "you need to run 'npm run shim' and commit the changes"
echo "$status"
exit 1
fi
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run Go linters
uses: golangci/golangci-lint-action@v3
with:
args: --verbose --timeout=5m
skip-pkg-cache: true
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run tests
run: go test -race ./...
integration-test:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.INTEGRATION_ATLAS_CLOUD_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- run: go install ./cmd/atlas-action
- uses: ./migrate/apply
with:
dir: file://atlasaction/testdata/migrations
url: sqlite://file.db?mode=memory
- uses: ./migrate/push
id: push_action
with:
dir: file://atlasaction/testdata/migrations
dir-name: test-dir
dev-url: sqlite://file.db?mode=memory
- name: "Verify migrate/push output"
shell: bash
run: |
# Verifies that the output we got is a URL as expected
[[ "${{ steps.push_action.outputs.url }}" =~ ^https://[a-zA-Z-]*\.atlasgo\.[a-zA-Z-]*/.*$ ]]
- name: lint_success
uses: ./migrate/lint
with:
dir: file://atlasaction/testdata/migrations
dev-url: sqlite://file.db?mode=memory
dir-name: test-dir
- name: lint_failure
uses: ./migrate/lint
with:
dir: file://atlasaction/testdata/migrations_destructive
dev-url: sqlite://file.db?mode=memory
dir-name: test-dir
- name: "Verify migrate/lint output"
shell: bash
run: |
# Verifies that the output we got for lint tests are URLs as expected
[[ "${{ steps.lint_failure.outputs.url }}" =~ ^https://[a-zA-Z-]*\.atlasgo\.[a-zA-Z-]*/.*$ ]]
[[ "${{ steps.lint_success.outputs.url }}" =~ ^https://[a-zA-Z-]*\.atlasgo\.[a-zA-Z-]*/.*$ ]]