# This is a basic workflow to help you get started with Actions

name: Linter

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  pull_request:
    branches: [ master, development, '**-RC' ]

permissions: {}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  lint:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    permissions:
      contents: read

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    - name: Get yarn cache directory
      id: cache_dir
      shell: bash
      run: |
        {
          echo 'cache_dir<<EOF'
          yarn cache dir
          echo EOF
        } >> "$GITHUB_OUTPUT"

    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
      with:
        persist-credentials: false

    - name: Use Node.js 24.x
      uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f #v6.3.0
      with:
        node-version: 24.x
        package-manager-cache: false

    # This workflow runs on pull requests which are untrusted
    # so we only restore the yarn cache, we don't save it to avoid cache poisoning
    - name: Restore yarn cache
      id: restore_cache
      uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 #v5.0.3
      with:
        key: ${{ format('node-cache-{0}-{1}-yarn-{2}', runner.os, runner.arch, hashFiles('yarn.lock')) }}
        path: ${{ steps.cache_dir.outputs.cache_dir }}

    - run: yarn run ci
      shell: bash
      env:
        ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
    - run: yarn run lint
      shell: bash
    # let's verify that webpack is able to package the project
    - run: yarn run pack
      shell: bash
    # verify that webpack is able to package the project using the web config
    - run: yarn run pack:web
      shell: bash
