|
| 1 | +name: TODO |
| 2 | +description: TODO |
| 3 | + |
| 4 | +inputs: |
| 5 | + path: |
| 6 | + description: A group directory or a glob pattern in order to find group directories and merge their metadata |
| 7 | + required: true |
| 8 | + token: |
| 9 | + description: Codecov upload token |
| 10 | + required: true |
| 11 | + follow-symbolic-links: |
| 12 | + description: | |
| 13 | + Indicates whether to follow symbolic links when resolving `path` |
| 14 | + default: 'true' |
| 15 | + |
| 16 | +outputs: |
| 17 | + groups: |
| 18 | + description: TODO |
| 19 | + value: ${{ steps.build-outputs.outputs.groups }} |
| 20 | + name: |
| 21 | + description: TODO |
| 22 | + value: ${{ steps.build-outputs.outputs.name }} |
| 23 | + reports: |
| 24 | + description: TODO |
| 25 | + value: ${{ steps.build-outputs.outputs.reports }} |
| 26 | + flags: |
| 27 | + description: TODO |
| 28 | + value: ${{ steps.build-outputs.outputs.flags }} |
| 29 | + |
| 30 | +runs: |
| 31 | + using: "composite" |
| 32 | + steps: |
| 33 | + # Even if an input is marked as "required", an empty value (or no value) may be passed ! |
| 34 | + - name: Validate inputs |
| 35 | + uses: actions/github-script@v7 |
| 36 | + env: |
| 37 | + INPUT_MAP: ${{ toJson(inputs) }} |
| 38 | + with: |
| 39 | + script: | |
| 40 | + return core.group( |
| 41 | + 'Validate inputs', |
| 42 | + async () => Object.entries(JSON.parse(process.env.INPUT_MAP)) |
| 43 | + .forEach(([key, val]) => { |
| 44 | + if (!val.trim()) { throw new Error(`Input required and not supplied: ${name}`); } |
| 45 | + }) |
| 46 | + ); |
| 47 | +
|
| 48 | + # @TODO move reports-group/load-metadata action to a dedicated repo and remove the checkout |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + path: custom-action-repo |
| 52 | + |
| 53 | + - name: Load groups metadata |
| 54 | + id: load-metadata |
| 55 | + uses: ./custom-action-repo/.github/actions/reports-group/load-metadata |
| 56 | + with: |
| 57 | + path: ${{ inputs.path }} |
| 58 | + format: string # String in order to concatenate interesting values |
| 59 | + glue-string: ',' # Ensure glue string as it's the expected one by the uploader |
| 60 | + follow-symbolic-links: ${{ inputs.follow-symbolic-links }} |
| 61 | + |
| 62 | + - name: Build uploader option |
| 63 | + id: build-uploader-options |
| 64 | + uses: actions/github-script@v7 |
| 65 | + env: |
| 66 | + METADATA: ${{ steps.load-metadata.outputs.metadata }} |
| 67 | + with: |
| 68 | + script: | |
| 69 | + core.info('Build uploader options'); |
| 70 | + const {METADATA} = process.env; |
| 71 | + |
| 72 | + const metadata = JSON.parse(METADATA); |
| 73 | + core.setOutput('name', metadata.name); |
| 74 | + core.setOutput('files', metadata.reportPaths); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`) |
| 75 | + if (metadata.flags.length > 0) { |
| 76 | + core.setOutput('flags', metadata.flags); |
| 77 | + } |
| 78 | +
|
| 79 | + - name: Ensure at least one report to upload |
| 80 | + if: ${{ '' == steps.build-uploader-options.outputs.files }} |
| 81 | + uses: actions/github-script@v7 |
| 82 | + with: |
| 83 | + script: | |
| 84 | + core.setFailed('Unable to retrieve any report to upload. Something wrong most likely happened !'); |
| 85 | +
|
| 86 | + - name: Upload to codacy |
| 87 | + id: upload |
| 88 | + uses: codecov/codecov-action@v4 |
| 89 | + with: |
| 90 | + token: ${{ inputs.token }} |
| 91 | + name: ${{ steps.build-uploader-options.outputs.name }} |
| 92 | + files: ${{ steps.build-uploader-options.outputs.files }} |
| 93 | + flags: ${{ steps.build-uploader-options.outputs.flags }} |
| 94 | + # underlying CLI behavior |
| 95 | + disable_search: true |
| 96 | + # GHAction behavior |
| 97 | + fail_ci_if_error: true |
| 98 | + verbose: ${{ runner.debug == '1' }} |
| 99 | + |
| 100 | + - name: Build action outputs |
| 101 | + id: build-outputs |
| 102 | + uses: actions/github-script@v7 |
| 103 | + env: |
| 104 | + METADATA: ${{ steps.load-metadata.outputs.metadata }} |
| 105 | + REPORT_NAME: ${{ steps.build-uploader-options.outputs.name }} |
| 106 | + REPORT_FILES: ${{ steps.build-uploader-options.outputs.files }} |
| 107 | + REPORT_FLAGS: ${{ steps.build-uploader-options.outputs.flags }} |
| 108 | + with: |
| 109 | + script: | |
| 110 | + core.info('Build output'); |
| 111 | + const {REPORT_NAME, REPORT_FILES, REPORT_FLAGS, METADATA} = process.env; |
| 112 | + |
| 113 | + const metadata = JSON.parse(METADATA); |
| 114 | + core.setOutput('group', metadata.path.split(',').join('\n')); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`) |
| 115 | + core.setOutput('name', REPORT_NAME); |
| 116 | + core.setOutput('reports', REPORT_FILES.split(',').join('\n')); // Trusted path, see `build-uploader-options` step |
| 117 | + core.setOutput('flags', undefined !== REPORT_FLAGS ? REPORT_FLAGS.split(',').join('\n') : ''); |
0 commit comments