|
| 1 | +name: Test JavaScript |
| 2 | + |
| 3 | +env: |
| 4 | + # See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml |
| 5 | + GO_VERSION: '1.21' |
| 6 | + # See: https://github.com/actions/setup-node/#readme |
| 7 | + NODE_VERSION: 18.17 |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + paths: |
| 12 | + - ".github/workflows/test-javascript.ya?ml" |
| 13 | + - "**/.mocharc.js" |
| 14 | + - "**/.mocharc.jsonc?" |
| 15 | + - "**/.mocharc.ya?ml" |
| 16 | + - "**/package.json" |
| 17 | + - "**/package-lock.json" |
| 18 | + - "**/yarn.lock" |
| 19 | + - "tests/testdata/**" |
| 20 | + - "**/tsconfig.json" |
| 21 | + - "**.[jt]sx?" |
| 22 | + pull_request: |
| 23 | + paths: |
| 24 | + - ".github/workflows/test-javascript.ya?ml" |
| 25 | + - "**/.mocharc.js" |
| 26 | + - "**/.mocharc.jsonc?" |
| 27 | + - "**/.mocharc.ya?ml" |
| 28 | + - "**/package.json" |
| 29 | + - "**/package-lock.json" |
| 30 | + - "**/yarn.lock" |
| 31 | + - "tests/testdata/**" |
| 32 | + - "**/tsconfig.json" |
| 33 | + - "**.[jt]sx?" |
| 34 | + workflow_dispatch: |
| 35 | + repository_dispatch: |
| 36 | + |
| 37 | +jobs: |
| 38 | + run-determination: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + permissions: {} |
| 41 | + outputs: |
| 42 | + result: ${{ steps.determination.outputs.result }} |
| 43 | + steps: |
| 44 | + - name: Determine if the rest of the workflow should run |
| 45 | + id: determination |
| 46 | + run: | |
| 47 | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" |
| 48 | + # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. |
| 49 | + if [[ |
| 50 | + "${{ github.event_name }}" != "create" || |
| 51 | + "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX |
| 52 | + ]]; then |
| 53 | + # Run the other jobs. |
| 54 | + RESULT="true" |
| 55 | + else |
| 56 | + # There is no need to run the other jobs. |
| 57 | + RESULT="false" |
| 58 | + fi |
| 59 | +
|
| 60 | + echo "result=$RESULT" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + test: |
| 63 | + name: test (${{ matrix.project.path }}, ${{ matrix.operating-system }}) |
| 64 | + needs: run-determination |
| 65 | + if: needs.run-determination.outputs.result == 'true' |
| 66 | + runs-on: ${{ matrix.operating-system }} |
| 67 | + defaults: |
| 68 | + run: |
| 69 | + shell: bash |
| 70 | + permissions: |
| 71 | + contents: read |
| 72 | + |
| 73 | + strategy: |
| 74 | + fail-fast: false |
| 75 | + matrix: |
| 76 | + project: |
| 77 | + - path: . |
| 78 | + operating-system: |
| 79 | + - macos-latest |
| 80 | + - ubuntu-latest |
| 81 | + - windows-latest |
| 82 | + |
| 83 | + steps: |
| 84 | + - name: Checkout |
| 85 | + uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Setup Node.js |
| 88 | + uses: actions/setup-node@v4 |
| 89 | + with: |
| 90 | + cache: yarn |
| 91 | + node-version: ${{ env.NODE_VERSION }} |
| 92 | + |
| 93 | + # See: https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites |
| 94 | + - name: Install Python |
| 95 | + uses: actions/setup-python@v5 |
| 96 | + with: |
| 97 | + python-version: '3.11.x' |
| 98 | + |
| 99 | + - name: Install Go |
| 100 | + uses: actions/setup-go@v5 |
| 101 | + with: |
| 102 | + go-version: ${{ env.GO_VERSION }} |
| 103 | + |
| 104 | + - name: Install Taskfile |
| 105 | + uses: arduino/setup-task@v2 |
| 106 | + with: |
| 107 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + version: 3.x |
| 109 | + |
| 110 | + - name: Install npm package dependencies |
| 111 | + env: |
| 112 | + # Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting: |
| 113 | + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + run: | |
| 116 | + yarn install |
| 117 | +
|
| 118 | + - name: Compile TypeScript |
| 119 | + run: | |
| 120 | + yarn \ |
| 121 | + --cwd arduino-ide-extension \ |
| 122 | + build |
| 123 | +
|
| 124 | + - name: Run tests |
| 125 | + env: |
| 126 | + # These secrets are optional. Dependent tests will be skipped if not available. |
| 127 | + CREATE_USERNAME: ${{ secrets.CREATE_USERNAME }} |
| 128 | + CREATE_PASSWORD: ${{ secrets.CREATE_PASSWORD }} |
| 129 | + CREATE_CLIENT_SECRET: ${{ secrets.CREATE_CLIENT_SECRET }} |
| 130 | + run: | |
| 131 | + yarn test |
| 132 | + yarn \ |
| 133 | + --cwd arduino-ide-extension \ |
| 134 | + test:slow |
0 commit comments