|
| 1 | +name: "[Features] - Test - Called" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + outputs: |
| 6 | + coverage_generated: |
| 7 | + value: ${{ jobs.test-features.outputs.coverage_generated }} |
| 8 | + |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + ref: |
| 12 | + description: | |
| 13 | + If you run this manually, and want to run on a PR, the correct ref should be refs/pull/{PR_NUMBER}/merge to |
| 14 | + have the "normal" scenario involving checking out a merge commit between your branch and the base branch. |
| 15 | + If you want to run only on a branch or specific commit, you can use either the sha or the branch name instead (prefer the first verion for PRs). |
| 16 | + required: false |
| 17 | + |
| 18 | +permissions: |
| 19 | + id-token: write |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + test-features: |
| 24 | + name: "Features Test" |
| 25 | + timeout-minutes: 20 |
| 26 | + env: |
| 27 | + NODE_OPTIONS: "--max-old-space-size=7168" |
| 28 | + FORCE_COLOR: 3 |
| 29 | + CI_OS: ubuntu-22.04 |
| 30 | + outputs: |
| 31 | + coverage_generated: ${{ contains(steps.generate_coverage.outcome, 'success') }} |
| 32 | + |
| 33 | + runs-on: [ledger-live-linux-8CPU-32RAM] |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 36 | + with: |
| 37 | + ref: ${{ inputs.ref || github.sha }} |
| 38 | + |
| 39 | + - name: Setup the caches |
| 40 | + uses: LedgerHQ/ledger-live/tools/actions/composites/setup-caches@develop |
| 41 | + id: setup-caches |
| 42 | + with: |
| 43 | + skip-turbo-cache: "false" |
| 44 | + install-proto: true |
| 45 | + accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }} |
| 46 | + roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }} |
| 47 | + region: ${{ secrets.AWS_CACHE_REGION }} |
| 48 | + turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }} |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: pnpm i --filter="./features/**" |
| 52 | + |
| 53 | + - name: Run coverage on feature packages |
| 54 | + run: | |
| 55 | + mkdir -p ${{ github.workspace }}/coverage |
| 56 | + touch ${{ github.workspace }}/coverage/lcov.info |
| 57 | + touch ${{ github.workspace }}/coverage/sonar-executionTests-report.xml |
| 58 | +
|
| 59 | + pnpm turbo run coverage --api="http://127.0.0.1:${{ steps.setup-caches.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" --filter="./features/**" --concurrency=4 -- --runInBand=1 |
| 60 | +
|
| 61 | + - name: Process coverage files |
| 62 | + id: process-coverage |
| 63 | + run: | |
| 64 | + for package_json in $(find ./features -name "package.json" -not -path "*/node_modules/*"); do |
| 65 | + pkg=$(dirname "$package_json") |
| 66 | + echo "Processing feature at path: $pkg" |
| 67 | + if [ -f "$package_json" ] && jq -e '.scripts.coverage' "$package_json" > /dev/null 2>&1; then |
| 68 | + if [ -f "$pkg/coverage/lcov.info" ] && [ -f "$pkg/coverage/sonar-executionTests-report.xml" ]; then |
| 69 | + echo "Appending coverage files for $pkg" |
| 70 | + cat "$pkg/coverage/lcov.info" >> ${{ github.workspace }}/coverage/lcov.info |
| 71 | + cat "$pkg/coverage/sonar-executionTests-report.xml" >> ${{ github.workspace }}/coverage/sonar-executionTests-report.xml |
| 72 | + fi |
| 73 | + else |
| 74 | + echo "No coverage script found for $pkg, skipping." |
| 75 | + fi |
| 76 | + done |
| 77 | + shell: bash |
| 78 | + |
| 79 | + - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 80 | + if: ${{ !cancelled() }} |
| 81 | + id: generate_coverage |
| 82 | + with: |
| 83 | + name: coverage-features |
| 84 | + path: ${{ github.workspace }}/coverage |
0 commit comments