@Libraries • Tests triggered by Sheng-Long on ref develop #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "@Libraries • Tests" | |
run-name: "@Libraries • Tests triggered by ${{ inputs.login || github.actor }} ${{ format('on ref {0}', github.ref_name) }}" | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
- release | |
- hotfix | |
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). | |
required: false | |
login: | |
description: The GitHub username that triggered the workflow | |
required: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name != 'develop' && github.ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
test-docs: | |
name: "Test Docs" | |
runs-on: ubuntu-latest | |
outputs: | |
fail: ${{ steps.diff.outputs.diff }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
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 | |
test-web-tools: | |
name: "Test web-tools" | |
env: | |
NODE_OPTIONS: "--max-old-space-size=7168" | |
FORCE_COLOR: 3 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
id: toolchain | |
with: | |
skip_turbo_cache: "false" | |
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }} | |
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }} | |
region: ${{ secrets.AWS_CACHE_REGION }} | |
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }} | |
- name: Install dependencies | |
run: pnpm i -F "web-tools..." -F "ledger-live" | |
- name: build web-tools | |
run: pnpm turbo run build --filter="web-tools" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" | |
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-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
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 | |
test-libraries: | |
name: "Test Libraries" | |
env: | |
NODE_OPTIONS: "--max-old-space-size=7168" | |
FORCE_COLOR: 3 | |
CI_OS: ubuntu-latest | |
runs-on: [ledger-live-4xlarge-linux] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
fetch-depth: 0 | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
id: toolchain | |
with: | |
skip_turbo_cache: "false" | |
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }} | |
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }} | |
region: ${{ secrets.AWS_CACHE_REGION }} | |
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }} | |
- name: Install dependencies | |
run: pnpm i --filter="!./apps/**" | |
- name: Build and Test affected libraries | |
id: test-libs | |
run: pnpm run test --continue --filter="!./apps/**" --filter="!./libs/ui/**" --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 | |
- name: scan ledger-live-common | |
if: ${{ hashFiles('libs/ledger-live-common/coverage/lcov.info') != '' }} | |
uses: sonarsource/sonarqube-scan-action@master | |
with: | |
projectBaseDir: ./libs/ledger-live-common | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_LEDGER_LIVE_COMMON }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: (On Failure) Upload live-common snapshots and source | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: live-common-src | |
path: | | |
libs/ledger-live-common/src | |
- uses: actions/github-script@v6 | |
if: always() | |
with: | |
script: | | |
const fs = require("fs"); | |
fs.writeFileSync("summary-tests.txt", "${{ steps.test-libs.outcome }}", "utf-8"); | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: outputs | |
path: ${{ github.workspace }}/summary-tests.txt | |
test-ui: | |
name: "Test UI Libs" | |
env: | |
NODE_OPTIONS: "--max-old-space-size=7168" | |
FORCE_COLOR: 3 | |
CI_OS: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
fetch-depth: 0 | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
id: toolchain | |
with: | |
skip_turbo_cache: "false" | |
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }} | |
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }} | |
region: ${{ secrets.AWS_CACHE_REGION }} | |
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }} | |
- uses: ruby/setup-ruby@v1 | |
if: ${{ matrix.os == 'macos-latest' }} | |
with: | |
ruby-version: 3.2.2 | |
- name: Install dependencies | |
run: pnpm i --filter="./libs/ui/**" | |
- name: Build and Test affected libraries | |
id: test-ui | |
run: pnpm run test --continue --filter="./libs/ui/**" --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 | |
- name: (On Failure) Upload react-ui test results | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: ${{ format('react-ui-test-results-{0}', matrix.os) }} | |
path: | | |
libs/ui/tests/react.spec.js-snapshots/ | |
libs/ui/test-results/ | |
- uses: actions/github-script@v6 | |
if: always() | |
with: | |
script: | | |
const fs = require("fs"); | |
fs.writeFileSync("summary-ui-${{ matrix.os }}.txt", "${{ steps.test-ui.outcome }}", "utf-8"); | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: outputs | |
path: ${{ github.workspace }}/summary-ui-${{ matrix.os }}.txt | |
codecheck-libraries: | |
name: "Codecheck Libraries" | |
env: | |
NODE_OPTIONS: "--max-old-space-size=7168" | |
FORCE_COLOR: 3 | |
CI_OS: ubuntu-latest | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.sha }} | |
fetch-depth: 0 | |
- name: Setup the toolchain | |
uses: ./tools/actions/composites/setup-toolchain | |
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: always() | |
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@v3 | |
if: always() | |
with: | |
name: outputs | |
path: | | |
${{ github.workspace }}/summary-typecheck.txt | |
${{ github.workspace }}/summary-lint.txt | |
report: | |
needs: [test-cli, test-docs, test-libraries, test-ui, codecheck-libraries, test-web-tools] | |
if: always() && !cancelled() && github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: outputs | |
- uses: actions/github-script@v6 | |
name: build summary | |
with: | |
script: | | |
const fs = require("fs"); | |
const resultTests = fs.readFileSync("${{ github.workspace }}/summary-tests.txt", "utf-8"); | |
const resultLint = fs.readFileSync("${{ github.workspace }}/summary-lint.txt", "utf-8"); | |
const resultTypecheck = fs.readFileSync("${{ github.workspace }}/summary-typecheck.txt", "utf-8"); | |
const resultUILinux = fs.readFileSync("${{ github.workspace }}/summary-ui-ubuntu-latest.txt", "utf-8"); | |
const resultUImacOS = fs.readFileSync("${{ github.workspace }}/summary-ui-macos-latest.txt", "utf-8"); | |
const resultUIWindows = fs.readFileSync("${{ github.workspace }}/summary-ui-windows-latest.txt", "utf-8"); | |
const statuses = { | |
doc: { | |
pass: ${{ needs.test-docs.outputs.fail != '1' }}, | |
status: "${{ needs.test-docs.result }}", | |
}, | |
tool: { | |
pass: ${{ needs.test-web-tools.result == 'success' }}, | |
status: "${{ needs.test-web-tools.result }}", | |
}, | |
cli: { | |
pass: ${{ needs.test-cli.outputs.test-fail == 'success' && needs.test-cli.outputs.fail != '1' }}, | |
status: "${{ needs.test-cli.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, | |
}, | |
ui: { | |
mac: { | |
pass: resultUImacOS == 'success', | |
status: resultUImacOS, | |
}, | |
linux: { | |
pass: resultUILinux == 'success', | |
status: resultUILinux, | |
}, | |
windows: { | |
pass: resultUIWindows == 'success', | |
status: resultUIWindows, | |
} | |
}, | |
}; | |
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}\` | |
### 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}\` | |
### 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}\` | |
### Test UI Design System | |
| Linux (🤖) | macOS (🍏) | windows (🪟) | | |
| :--: | :--: | :--: | | |
| ${statuses.ui.linux.pass ? "✅" : "❌"} (${statuses.ui.linux.status}) | ${statuses.ui.mac.pass ? "✅" : "❌"} (${statuses.ui.mac.status}) | ${statuses.ui.windows.pass ? "✅" : "❌"} (${statuses.ui.windows.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.json", JSON.stringify(output), "utf-8"); | |
- uses: actions/upload-artifact@v3 | |
name: Upload output | |
with: | |
path: ${{ github.workspace }}/summary.json | |
name: summary.json |