Skip to content

Merge pull request #13 from github/add-copilot-sdk-java-instructions #33

Merge pull request #13 from github/add-copilot-sdk-java-instructions

Merge pull request #13 from github/add-copilot-sdk-java-instructions #33

Workflow file for this run

name: "Build & Test"
on:
schedule:
# Run once a week on Sundays at 00:00 UTC
- cron: '0 0 * * 0'
push:
branches: [main]
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.github/**'
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.github/**'
workflow_dispatch:
merge_group:
permissions:
contents: write
checks: write
jobs:
java-sdk:
name: "Java SDK Tests"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "17"
distribution: "temurin"
cache: "maven"
- name: Run spotless check
run: |
mvn spotless:check
if [ $? -ne 0 ]; then
echo "❌ spotless:check failed. Please run 'mvn spotless:apply' in java"
exit 1
fi
echo "✅ spotless:check passed"
- name: Build SDK and clone test harness
run: mvn test-compile
- name: Verify Javadoc generation
run: mvn javadoc:javadoc -q
- name: Install Copilot CLI from cloned SDK
id: setup-copilot
run: |
# Install dependencies in the cloned SDK's nodejs directory
# This ensures we use the same CLI version as the test harness expects
cd target/copilot-sdk/nodejs
npm ci --ignore-scripts
echo "path=$(pwd)/node_modules/@github/copilot/index.js" >> $GITHUB_OUTPUT
- name: Verify CLI works
run: node ${{ steps.setup-copilot.outputs.path }} --version
- name: Run Java SDK tests
env:
CI: "true"
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.path }}
run: mvn verify
- name: Upload test results for site generation
if: success() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: test-results-for-site
path: |
target/jacoco-test-results/sdk-tests.exec
target/surefire-reports/
retention-days: 1
- name: Generate and commit JaCoCo badge
if: success() && github.ref == 'refs/heads/main'
run: |
.github/scripts/generate-coverage-badge.sh
# Commit if changed
if [[ $(git status --porcelain .github/badges/) ]]; then
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add .github/badges/
git commit -m "Update JaCoCo coverage badge"
git push
fi
- name: Generate Test Report Summary
if: always()
uses: ./.github/actions/test-report