diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cc5af4b53..a5108c1e2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 @@ -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 @@ -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 + + - 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 }} diff --git a/services/sqlserverflex/v2api/wait/wait.go b/services/sqlserverflex/v2api/wait/wait.go index 5d53eb280..4edc55661 100644 --- a/services/sqlserverflex/v2api/wait/wait.go +++ b/services/sqlserverflex/v2api/wait/wait.go @@ -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] { return createOrUpdateInstanceWaitHandler(ctx, client, projectId, instanceId, region) }