|
| 1 | +name: Test Claude Changelog Action |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-action: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: "20" |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + cd . |
| 31 | + npm install |
| 32 | +
|
| 33 | + - name: Test action (dry run without API key) |
| 34 | + env: |
| 35 | + ANTHROPIC_API_KEY: "test-key-placeholder" |
| 36 | + CHANGELOG_PATH: "test-changelog.md" |
| 37 | + TARGET: "test" |
| 38 | + LATEST_TAG: "v1.0.0" |
| 39 | + COMMIT_COUNT: "5" |
| 40 | + GITHUB_EVENT_NAME: "push" |
| 41 | + VERSION_INCREMENT: "patch" |
| 42 | + run: | |
| 43 | + # Create test data |
| 44 | + echo "abc123|feat: add new feature|test-author|2025-01-20" > recent_commits.txt |
| 45 | + echo "def456|fix: resolve bug|test-author|2025-01-20" >> recent_commits.txt |
| 46 | + echo "src/app.js" > changed_files.txt |
| 47 | + echo "src/utils.js" >> changed_files.txt |
| 48 | +
|
| 49 | + # Test script validation (will fail on API call but should validate structure) |
| 50 | + node lib/generate-changelog.js || echo "Expected to fail without valid API key" |
| 51 | +
|
| 52 | + # Check that the script doesn't crash on file parsing |
| 53 | + if [ ! -f changelog_status.txt ]; then |
| 54 | + echo "Error: changelog_status.txt was not created" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | +
|
| 58 | + echo "✅ Script structure validation passed" |
| 59 | +
|
| 60 | + lint-and-validate: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Setup Node.js |
| 68 | + uses: actions/setup-node@v4 |
| 69 | + with: |
| 70 | + node-version: "20" |
| 71 | + |
| 72 | + - name: Install dependencies |
| 73 | + run: | |
| 74 | + npm install |
| 75 | + npm install js-yaml |
| 76 | +
|
| 77 | + - name: Validate action.yml |
| 78 | + run: | |
| 79 | + # Basic YAML validation |
| 80 | + node -e " |
| 81 | + const yaml = require('js-yaml'); |
| 82 | + const fs = require('fs'); |
| 83 | + try { |
| 84 | + const doc = yaml.load(fs.readFileSync('action.yml', 'utf8')); |
| 85 | + console.log('✅ action.yml is valid YAML'); |
| 86 | +
|
| 87 | + // Check required fields |
| 88 | + if (!doc.name) throw new Error('Missing name field'); |
| 89 | + if (!doc.description) throw new Error('Missing description field'); |
| 90 | + if (!doc.runs) throw new Error('Missing runs field'); |
| 91 | + if (!doc.inputs) throw new Error('Missing inputs field'); |
| 92 | + if (!doc.outputs) throw new Error('Missing outputs field'); |
| 93 | +
|
| 94 | + console.log('✅ action.yml has required fields'); |
| 95 | + } catch (e) { |
| 96 | + console.error('❌ action.yml validation failed:', e.message); |
| 97 | + process.exit(1); |
| 98 | + } |
| 99 | + " |
| 100 | +
|
| 101 | + - name: Check Node.js syntax |
| 102 | + run: | |
| 103 | + node -c lib/generate-changelog.js |
| 104 | + echo "✅ JavaScript syntax is valid" |
| 105 | +
|
| 106 | + integration-test: |
| 107 | + runs-on: ubuntu-latest |
| 108 | + if: github.event_name == 'workflow_dispatch' |
| 109 | + permissions: |
| 110 | + contents: write |
| 111 | + pull-requests: write |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Checkout |
| 115 | + uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + fetch-depth: 0 |
| 118 | + |
| 119 | + - name: Test the action |
| 120 | + uses: ./ |
| 121 | + with: |
| 122 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 123 | + changelog_path: "TEST_CHANGELOG.md" |
| 124 | + target_name: "integration-test" |
| 125 | + auto_commit: false |
| 126 | + continue-on-error: true |
| 127 | + |
| 128 | + - name: Check outputs |
| 129 | + run: | |
| 130 | + echo "Status: ${{ steps.test.outputs.status }}" |
| 131 | + echo "Updated: ${{ steps.test.outputs.changelog_updated }}" |
| 132 | + echo "Has changes: ${{ steps.test.outputs.has_changes }}" |
0 commit comments