Skip to content

Commit

Permalink
.github/workflows: ci test vs cloud account
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemtam committed Jul 30, 2023
1 parent 6b90a85 commit 3f17fdd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
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

0 comments on commit 3f17fdd

Please sign in to comment.