|
| 1 | +name: Internal - Tests for "release/get-configuration" action |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: {} |
| 7 | + |
| 8 | +jobs: |
| 9 | + tests: |
| 10 | + name: Tests for "release/get-configuration" action |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + steps: |
| 15 | + - name: Arrange - Checkout |
| 16 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 17 | + with: |
| 18 | + persist-credentials: false |
| 19 | + |
| 20 | + - name: Arrange - Create repository config fixture |
| 21 | + run: | |
| 22 | + mkdir -p .github |
| 23 | + cat <<'EOF' > .github/release-config.yml |
| 24 | + --- |
| 25 | + template: | |
| 26 | + $CHANGES |
| 27 | + EOF |
| 28 | +
|
| 29 | + - name: Act - Resolve existing repository config |
| 30 | + id: existing-config |
| 31 | + uses: ./actions/release/get-configuration |
| 32 | + |
| 33 | + - name: Assert - Existing repository config |
| 34 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 35 | + env: |
| 36 | + CONFIG_PATH: ${{ steps.existing-config.outputs.config-path }} |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const assert = require('node:assert'); |
| 40 | + const fs = require('node:fs'); |
| 41 | + const path = require('node:path'); |
| 42 | +
|
| 43 | + const workspace = process.env.GITHUB_WORKSPACE || process.cwd(); |
| 44 | + const configPath = process.env.CONFIG_PATH; |
| 45 | +
|
| 46 | + assert.equal(configPath, 'release-config.yml'); |
| 47 | +
|
| 48 | + const absoluteConfigPath = path.resolve(workspace, '.github', configPath); |
| 49 | + assert.ok(fs.existsSync(absoluteConfigPath), `Expected config to exist at ${absoluteConfigPath}`); |
| 50 | +
|
| 51 | + - name: Act - Resolve generated temp config |
| 52 | + id: generated-config |
| 53 | + uses: ./actions/release/get-configuration |
| 54 | + with: |
| 55 | + working-directory: actions/release/get-configuration |
| 56 | + include-paths: '["actions/release/create"]' |
| 57 | + |
| 58 | + - name: Assert - Generated temp config |
| 59 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 60 | + env: |
| 61 | + CONFIG_PATH: ${{ steps.generated-config.outputs.config-path }} |
| 62 | + with: |
| 63 | + script: | |
| 64 | + const assert = require('node:assert'); |
| 65 | + const fs = require('node:fs'); |
| 66 | + const path = require('node:path'); |
| 67 | +
|
| 68 | + const workspace = process.env.GITHUB_WORKSPACE || process.cwd(); |
| 69 | + const configPath = process.env.CONFIG_PATH; |
| 70 | + const absoluteConfigPath = path.resolve(workspace, '.github', configPath); |
| 71 | + const configContent = fs.readFileSync(absoluteConfigPath, 'utf8'); |
| 72 | +
|
| 73 | + assert.notEqual(configPath, 'release-configs/get-configuration.yml'); |
| 74 | + assert.ok(configPath.endsWith('/release-drafter/get-configuration.yml') || configPath === '../release-drafter/get-configuration.yml' || configPath.includes('/release-drafter/get-configuration.yml')); |
| 75 | + assert.ok(fs.existsSync(absoluteConfigPath), `Expected generated config to exist at ${absoluteConfigPath}`); |
| 76 | + assert.ok(configContent.includes('include-paths:'), 'Expected include-paths section in generated config'); |
| 77 | + assert.ok(configContent.includes(' - "actions/release/create"'), 'Expected custom include path in generated config'); |
| 78 | + assert.ok(configContent.includes(' - "actions/release/get-configuration"'), 'Expected working directory include path in generated config'); |
| 79 | + assert.ok(configContent.includes('name-template: "Version get-configuration - $RESOLVED_VERSION"'), 'Expected working-directory-specific name template'); |
| 80 | + assert.ok(configContent.includes('tag-prefix: "get-configuration-"'), 'Expected working-directory-specific tag prefix'); |
0 commit comments