Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

tusk-test-runner-app-vitest-unit-tests.yml 3.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  1. name: Tusk Test Runner - Vitest unit tests (src/app)
  2. # Required for Tusk
  3. permissions:
  4. contents: read
  5. on:
  6. workflow_dispatch:
  7. inputs:
  8. runId:
  9. description: 'Tusk Run ID'
  10. required: true
  11. tuskUrl:
  12. description: 'Tusk server URL'
  13. required: true
  14. commitSha:
  15. description: 'Commit SHA to checkout'
  16. required: true
  17. jobs:
  18. test-action:
  19. name: Tusk Test Runner
  20. runs-on: ubuntu-latest
  21. steps:
  22. - name: Checkout
  23. id: checkout
  24. uses: actions/checkout@v4
  25. with:
  26. ref: ${{ github.event.inputs.commitSha }} # Required for Tusk to access files for the commit being tested
  27. - name: Use Node
  28. uses: actions/setup-node@v4
  29. with:
  30. node-version-file: '.nvmrc'
  31. cache: 'npm'
  32. - name: Install Dependencies
  33. run: npm ci
  34. - name: Start runner
  35. id: test-action
  36. uses: Use-Tusk/test-runner@v1
  37. # See https://github.com/Use-Tusk/test-runner for full details and examples.
  38. with:
  39. # Required for the test runner, do not remove this input
  40. runId: ${{ github.event.inputs.runId }}
  41. # Required for the test runner, do not remove this input
  42. tuskUrl: ${{ github.event.inputs.tuskUrl }}
  43. # Required for the test runner, do not remove this input
  44. commitSha: ${{ github.event.inputs.commitSha }}
  45. # Your Tusk auth token. It is recommended to add it to your repo's secrets.
  46. # Please adapt the secret name accordingly if you have named it differently.
  47. authToken: ${{ secrets.TUSK_AUTH_TOKEN }}
  48. # Vitest for the React app tests
  49. testFramework: 'Vitest'
  50. # Test file regex to match Vitest test files in src/app
  51. testFileRegex: '^src/app/.*\.(test|spec)\.(js|jsx|ts|tsx)$'
  52. # This will be the working directory for all commands
  53. appDir: 'src/app'
  54. # The script to run to lint the code for React/TypeScript files
  55. # Create a unique tsconfig file so we can check tsc just for the file
  56. lintScript: |
  57. set -e
  58. # Create a tsconfig file just for the input file
  59. # https://stackoverflow.com/questions/44676944/how-to-compile-a-specific-file-with-tsc-using-the-paths-compiler-option/60950355#60950355
  60. FILENAME=$(echo "{{file}}" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')
  61. TIMESTAMP=$(date +%s)
  62. TMP_TSCONFIG=".tsconfig-lint-${FILENAME}-${TIMESTAMP}.json"
  63. # Set up trap to remove temp file on exit, even if there's an error
  64. trap "rm -f $TMP_TSCONFIG" EXIT
  65. npx prettier --write {{file}}
  66. npx eslint --fix {{file}} --no-warn-ignored
  67. cat >$TMP_TSCONFIG <<EOF
  68. {
  69. "extends": "./tsconfig.json",
  70. "include": [
  71. "{{file}}",
  72. "**/*.d.ts"
  73. ]
  74. }
  75. EOF
  76. # Run tsc with the temp tsconfig file
  77. npx tsc --project $TMP_TSCONFIG --skipLibCheck --noEmit
  78. # The script to run Vitest tests for individual files
  79. testScript: 'npx vitest run {{file}}'
  80. # The runner may run tests in parallel.
  81. # Set this value to 1 if you know that your tests should not be run concurrently.
  82. # maxConcurrency: 1
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...