Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github/workflows: ci test vs cloud account #6

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions .github/workflows/ci-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,40 @@ jobs:
load: true
- run: docker images
- name: sanity
id: sanity
uses: ./internal/action
with:
url: sqlite://file.db
dir: ./internal/testdata/migrations
- run: |
curl -sSf 'https://atlasgo.sh?test=1' | env ATLAS_DEBUG=true sh
atlas migrate status --url sqlite://file.db --dir file://./internal/testdata/migrations
output=$(atlas migrate status --url sqlite://file.db --dir file://./internal/testdata/migrations)
if [[ "$output" == *"Already at latest version"* ]]; then
echo "OK"
url: sqlite://internal/testdata/test.db
cloud-dir: migrations
cloud-token: ${{ secrets.ATLAS_CLOUD_TEST_TOKEN }}
cloud-url: ${{ secrets.ATLAS_CLOUD_TEST_URL }}
- name: Check Error and Compare Current with Target
run: |
error_output="${{ steps.sanity.outputs.error }}"
pending_output="${{ steps.sanity.outputs.pending_count }}"
applied_output="${{ steps.sanity.outputs.applied_count }}"

# Check that the "error" output is empty
if [ -z "$error_output" ]; then
echo "No error occurred in the action."
else
echo "Error occurred: $error_output"
exit 1
fi

# Check that the "pending" output "0"
if [ "$pending_output" -eq "0" ]; then
echo "No pending migrations."
else
echo "Pending migrations: $pending_output"
exit 1
fi

# Check that the "applied" output is "0"
if [ "$applied_output" -eq "0" ]; then
echo "No migrations applied."
else
echo "Expected 'Already at latest version', got '$output'"
echo "Migrations applied: $applied_output"
exit 1
fi
docker:
Expand Down
Binary file added internal/testdata/test.db
Binary file not shown.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func main() {
if err != nil {
act.Fatalf("failed to run: %v", err)
}
act.SetOutput("error", run.Error)
act.SetOutput("current", run.Current)
act.SetOutput("target", run.Target)
act.SetOutput("pending_count", strconv.Itoa(len(run.Pending)))
act.SetOutput("applied_count", strconv.Itoa(len(run.Applied)))
act.Infof("Run complete: +%v", run)
}

Expand Down
Loading