Skip to content

Commit

Permalink
Merge pull request #7818 from LedgerHQ/fix/restore-tests-ci
Browse files Browse the repository at this point in the history
Restore missing workflows
  • Loading branch information
KVNLS authored Sep 16, 2024
2 parents 4b7aa70 + 35c0c6f commit 51a32cc
Show file tree
Hide file tree
Showing 5 changed files with 366 additions and 16 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build-and-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ jobs:
uses: LedgerHQ/ledger-live/.github/workflows/test-design-system-reusable.yml@develop
secrets: inherit

test-web-tools:
name: "Test Web Tools"
needs: determine-affected
if: ${{contains(needs.determine-affected.outputs.paths, 'apps/web-tools') && github.event.pull_request.head.repo.full_name == github.repository}}
uses: LedgerHQ/ledger-live/.github/workflows/test-web-tools-reusable.yml@develop
secrets: inherit

test-cli:
name: "Test CLI"
needs: determine-affected
if: ${{contains(needs.determine-affected.outputs.paths, 'apps/cli') && github.event.pull_request.head.repo.full_name == github.repository}}
uses: LedgerHQ/ledger-live/.github/workflows/test-cli-reusable.yml@develop
secrets: inherit

# Final Check required
ok:
name: "OK"
Expand All @@ -82,6 +96,8 @@ jobs:
- test-mobile-e2e
- test-libraries
- test-design-system
- test-web-tools
- test-cli
runs-on: ubuntu-22.04
if: always() && !cancelled()
steps:
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/test-cli-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "CLI Tests"

on:
workflow_call:
workflow_dispatch:
inputs:
ref:
description: |
If you run this manually, and want to run on a PR, the correct ref should be refs/pull/{PR_NUMBER}/merge to
have the "normal" scenario involving checking out a merge commit between your branch and the base branch.
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).
required: false

permissions:
id-token: write
contents: read

jobs:
test-cli:
name: "Test CLI"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
outputs:
fail: ${{ steps.diff.outputs.diff }}
test-fail: ${{ steps.test.outcome }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup the toolchain
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-toolchain@develop
id: toolchain
with:
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }}
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }}
region: ${{ secrets.AWS_CACHE_REGION }}
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }}
skip-turbo-cache: "false"
- name: Install dependencies
run: pnpm i -F "live-cli..." -F "ledger-live"
- name: build cli
run: pnpm build:cli --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
- name: lint cli
run: pnpm lint --filter="live-cli" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" -- --quiet
- name: typecheck cli
run: pnpm typecheck --filter="live-cli" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
- name: test cli
id: test
run: pnpm run test --filter="live-cli" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
- name: get diff
id: diff
run: |
diff=$(git diff --exit-code > /dev/null && echo 0 || echo 1)
echo "diff=$diff" >> $GITHUB_OUTPUT
exit $diff
report:
needs: test-cli
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
with:
pattern: outputs-*
merge-multiple: true
path: outputs
- uses: actions/github-script@v6
name: build summary
with:
script: |
const fs = require("fs");
const statuses = {
cli: {
pass: ${{ needs.test-cli.outputs.test-fail == 'success' && needs.test-cli.outputs.fail != '1' }},
status: "${{ needs.test-cli.result }}",
}
};
const summary = `### Test CLI
${statuses.cli.pass ? "CLI tests are successful" : "CLI tests did not end successfully"}
- ${statuses.cli.pass ? "✅" : "❌"} **CLI tests** ended with status \`${statuses.cli.status}\`
`;
const output = {
summary
};
fs.writeFileSync("summary-cli.json", JSON.stringify(output), "utf-8");
- uses: actions/upload-artifact@v4
name: Upload output
with:
path: ${{ github.workspace }}/summary-cli.json
name: summary-cli.json
184 changes: 171 additions & 13 deletions .github/workflows/test-libs-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ on:
workflow_call:
workflow_dispatch:
inputs:
since_branch:
description: The branch that turborepo will check when diffing.
default: "develop"
ref:
description: |
If you run this manually, and want to run on a PR, the correct ref should be refs/pull/{PR_NUMBER}/merge to
have the "normal" scenario involving checking out a merge commit between your branch and the base branch.
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).
type: string
required: false
login:
description: The GitHub username that triggered the workflow
type: string
required: false
base_ref:
description: The base branch to merge the head into when checking out the code
type: string
required: false
prNumber:
description: PR number
type: string
required: false

permissions:
Expand Down Expand Up @@ -76,3 +66,171 @@ jobs:
with:
name: outputs-test-libraries
path: ${{ github.workspace }}/summary-tests.txt

codecheck-libraries:
name: "Codecheck Libraries"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-22.04

runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
fetch-depth: 0
- name: Setup the toolchain
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-toolchain@develop
id: toolchain
with:
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }}
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }}
region: ${{ secrets.AWS_CACHE_REGION }}
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }}
skip-turbo-cache: "false"
- name: Install dependencies
run: pnpm i --filter="!./apps/**"
- name: Lint affected libraries
id: lint-libs
run: pnpm lint --continue --filter="!./apps/**" --filter="!./tools/**" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" -- --quiet
- name: Typecheck affected libraries
id: typecheck-libs
run: pnpm typecheck --continue --filter="!./apps/**" --filter="!./tools/**" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
- name: Test unimported files
id: unimported
run: pnpm unimported --continue --filter="!./apps/**" --filter="!./tools/**" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
shell: bash
- uses: actions/github-script@v6
if: ${{ !cancelled() }}
with:
script: |
const fs = require("fs");
fs.writeFileSync("summary-typecheck.txt", "${{ steps.typecheck-libs.outcome }}", "utf-8");
fs.writeFileSync("summary-lint.txt", "${{ steps.lint-libs.outcome }}", "utf-8");
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: outputs-codecheck
path: |
${{ github.workspace }}/summary-typecheck.txt
${{ github.workspace }}/summary-lint.txt
test-docs:
name: "Test Docs"
runs-on: ubuntu-22.04
outputs:
fail: ${{ steps.diff.outputs.diff }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup the toolchain
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-toolchain@develop
id: toolchain
with:
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }}
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }}
region: ${{ secrets.AWS_CACHE_REGION }}
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }}
skip-turbo-cache: "false"
- name: Install dependencies
run: pnpm i --filter="!./apps/**"
- name: run doc
run: pnpm doc:ljs --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo"
- name: get diff
id: diff
run: |
diff=$(git diff --exit-code > /dev/null && echo 0 || echo 1)
echo "diff=$diff" >> $GITHUB_OUTPUT
exit $diff
report:
needs: [test-docs, test-libraries, codecheck-libraries]
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: outputs-*
merge-multiple: true
path: outputs
- uses: actions/github-script@v6
name: build summary
with:
script: |
const fs = require("fs");
const resultTests = fs.readFileSync("${{ github.workspace }}/outputs/summary-tests.txt", "utf-8");
const resultLint = fs.readFileSync("${{ github.workspace }}/outputs/summary-lint.txt", "utf-8");
const resultTypecheck = fs.readFileSync("${{ github.workspace }}/outputs/summary-typecheck.txt", "utf-8");
const statuses = {
doc: {
pass: ${{ needs.test-docs.outputs.fail != '1' }},
status: "${{ needs.test-docs.result }}",
},
codecheck: {
pass: ${{ needs.codecheck-libraries.result == 'success' }},
status: "${{ needs.codecheck-libraries.result }}",
},
tests: {
pass: ${{ needs.test-libraries.result == 'success' }},
status: "${{ needs.test-libraries.result }}",
},
lint: {
pass: resultLint == 'success',
status: resultLint,
},
typecheck: {
pass: resultTypecheck == 'success',
status: resultTypecheck,
},
};
const summary = `### Test documentation files
${statuses.doc.pass ? "Documentation files are fine" : "Documentation files are outdated"}
- ${statuses.doc.pass ? "✅" : "❌"} **Test documentation files** ended with status \`${statuses.doc.status}\`
### Codecheck Libraries
${statuses.codecheck.pass ? "Codecheck was successfull" : "Codecheck failed"}
- ${statuses.codecheck.pass ? "✅" : "❌"} **Codecheck** ended with status \`${statuses.codecheck.status}\`
| Lint | Typecheck |
| :--: | :--: |
| ${statuses.lint.pass ? "✅" : "❌"} (${statuses.lint.status}) | ${statuses.typecheck.pass ? "✅" : "❌"} (${statuses.typecheck.status}) |
### Test Libraries
${statuses.tests.pass ? "All tests are fine" : "Some tests failed"}
- ${statuses.tests.pass ? "✅" : "❌"} **Test Libs** ended with status \`${statuses.tests.status}\`
### Common Tools
${statuses.tool.pass ? "Common Tools are fine" : "Common Tools tests failed"}
- ${statuses.tool.pass ? "✅" : "❌"} **Common Tools* tests* ended with status \`${statuses.tool.status}\`
`;
const actions = [];
if (${{ needs.test-docs.outputs.fail == '1' }}) {
actions.push({
// 20 chars max
label: "Regen. Doc Files",
// 20 chars max
identifier: "regen_doc",
// 40 chars max
description: "Will regenerate doc files for ljs",
});
}
const output = {
summary,
actions
};
fs.writeFileSync("summary-libraries.json", JSON.stringify(output), "utf-8");
- uses: actions/upload-artifact@v4
name: Upload output
with:
path: ${{ github.workspace }}/summary-libraries.json
name: summary-libraries.json
Loading

0 comments on commit 51a32cc

Please sign in to comment.