Skip to content
Open
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
114 changes: 114 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: CI Workflow

on: [pull_request, workflow_dispatch]

permissions:
pull-requests: write # required to add comments to the PR
contents: read

jobs:
main:
name: CI
Expand All @@ -13,10 +17,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Test
run: make test

Expand All @@ -29,13 +35,121 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.25

- name: Install project tools and dependencies
run: make project-tools

- name: Lint
run: |
make lint
scripts/check-sync-tidy.sh

detect-sdk-modules:
name: Detect changed SDK modules
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed Go modules
id: set-matrix
run: |
MODULES=()

# Find all directories containing a go.mod file
for mod in $(find . -name "go.mod" | sort); do
dir=$(dirname "$mod")

# Clean up the path (e.g., convert "./module" to "module", and "." remains ".")
dir=${dir#./}

# Check if there are differences in this directory compared to the base branch
if ! git diff --quiet origin/${{ github.base_ref }} HEAD -- "$dir"; then
MODULES+=("\"$dir\"")
fi
done

# Format as a JSON array for the matrix job
JSON="[$(IFS=,; echo "${MODULES[*]}")]"
echo "Changed modules: $JSON"
echo "matrix=$JSON" >> $GITHUB_OUTPUT

gorelease-check:
name: Run gorelease check
needs: [ "detect-sdk-modules" ]
# Skip the entire job if the JSON array is empty (no modules changed)
if: ${{ needs.detect-sdk-modules.outputs.matrix != '[]' && needs.detect-sdk-modules.outputs.matrix != '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.detect-sdk-modules.outputs.matrix) }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.25

- name: Install gorelease
run: go install golang.org/x/exp/cmd/gorelease@latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use here a specific version or commit hash, to prevent unexpected changed


- name: Run gorelease
id: gorelease
working-directory: ${{ matrix.module }}
run: |
# Disable "exit on error" temporarily so we can capture the output
# even if gorelease finds backwards incompatibilities (which causes exit code 1)
set +e
OUTPUT=$(gorelease 2>&1)
EXIT_CODE=$?
set -e

# Securely write multi-line output to GITHUB_OUTPUT using EOF marker
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "report<<$EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT

# Save the exit code to evaluate later
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT

- name: Comment PR
uses: actions/github-script@v7
env:
REPORT: ${{ steps.gorelease.outputs.report }}
MODULE: ${{ matrix.module }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const report = process.env.REPORT || "No output generated.";
const module = process.env.MODULE;

// Format the comment
const body = `### \`gorelease\` report for \`${module}\`\n\n\`\`\`text\n${report}\n\`\`\``;

// Post the comment to the PR
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})

- name: Fail job if gorelease failed
if: ${{ steps.gorelease.outputs.exit_code != '0' }}
run: |
echo "gorelease exited with code ${{ steps.gorelease.outputs.exit_code }}"
exit ${{ steps.gorelease.outputs.exit_code }}
2 changes: 1 addition & 1 deletion services/sqlserverflex/v2api/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func CreateInstanceWaitHandler(ctx context.Context, client sqlserverflex.Default
}

// UpdateInstanceWaitHandler will wait for instance update
func UpdateInstanceWaitHandler(ctx context.Context, client sqlserverflex.DefaultAPI, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
func FooUpdateInstanceWaitHandler(ctx context.Context, client sqlserverflex.DefaultAPI, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert before merge

Changed just for testing purpose.

return createOrUpdateInstanceWaitHandler(ctx, client, projectId, instanceId, region)
}

Expand Down
Loading