|  | 
|  | 1 | +name: Test External | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  push: | 
|  | 5 | +    branches: | 
|  | 6 | +      - master | 
|  | 7 | +    tags: | 
|  | 8 | +      - '*' | 
|  | 9 | +  pull_request: | 
|  | 10 | +    branches: | 
|  | 11 | +      - master | 
|  | 12 | +  workflow_dispatch: | 
|  | 13 | +    inputs: | 
|  | 14 | +      moduleSet: | 
|  | 15 | +        description: 'Module set' | 
|  | 16 | +        required: true | 
|  | 17 | +        default: 'nonCompliant' | 
|  | 18 | +        type: choice | 
|  | 19 | +        options: | 
|  | 20 | +        - compliant | 
|  | 21 | +        - nonCompliant | 
|  | 22 | + | 
|  | 23 | +concurrency: | 
|  | 24 | +  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | 
|  | 25 | +  cancel-in-progress: true | 
|  | 26 | + | 
|  | 27 | +permissions: | 
|  | 28 | +  contents: read | 
|  | 29 | + | 
|  | 30 | +jobs: | 
|  | 31 | +  read_external_projects: | 
|  | 32 | +    name: Read list of ${{ github.event.inputs.moduleSet || 'compliant' }} external projects | 
|  | 33 | +    runs-on: ubuntu-latest | 
|  | 34 | +    outputs: | 
|  | 35 | +      matrix: ${{ steps.set-matrix.outputs.matrix }} | 
|  | 36 | +    steps: | 
|  | 37 | +      - uses: actions/checkout@v3 | 
|  | 38 | +      - id: set-matrix | 
|  | 39 | +        run: echo "matrix=$(cat workflow-external.json | jq -c '.${{ github.event.inputs.moduleSet || 'compliant' }}')" >> $GITHUB_OUTPUT | 
|  | 40 | +  test_external: | 
|  | 41 | +    needs: read_external_projects | 
|  | 42 | +    name: Test ${{ matrix.project }} | 
|  | 43 | +    runs-on: ubuntu-latest | 
|  | 44 | +    strategy: | 
|  | 45 | +      fail-fast: false | 
|  | 46 | +      matrix: | 
|  | 47 | +        node_version: [lts/*] | 
|  | 48 | +        project: ${{ fromJson(needs.read_external_projects.outputs.matrix) }} | 
|  | 49 | +    steps: | 
|  | 50 | +      - name: Checkout main project | 
|  | 51 | +        uses: actions/checkout@v3 | 
|  | 52 | +        with: | 
|  | 53 | +          path: main | 
|  | 54 | +      - name: Checkout ${{ matrix.project }} | 
|  | 55 | +        uses: actions/checkout@v3 | 
|  | 56 | +        with: | 
|  | 57 | +          repository: ${{ matrix.project }} | 
|  | 58 | +          path: project | 
|  | 59 | +      - name: Use Node.js ${{ matrix.node_version }} | 
|  | 60 | +        uses: actions/setup-node@v3 | 
|  | 61 | +        with: | 
|  | 62 | +          node-version: ${{ matrix.node_version }} | 
|  | 63 | + | 
|  | 64 | +      - name: Determine npm cache directory windows | 
|  | 65 | +        id: npm-cache-dir-windows | 
|  | 66 | +        if: runner.os == 'Windows' | 
|  | 67 | +        run: echo "dir=$(npm config get cache)" >> $env:GITHUB_OUTPUT | 
|  | 68 | +      - name: Determine npm cache directory non-windows | 
|  | 69 | +        id: npm-cache-dir | 
|  | 70 | +        if: runner.os != 'Windows' | 
|  | 71 | +        run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT | 
|  | 72 | +      - uses: actions/cache@v3 | 
|  | 73 | +        with: | 
|  | 74 | +          path: ${{ steps.npm-cache-dir-windows.outputs.dir || steps.npm-cache-dir.outputs.dir }} | 
|  | 75 | +          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/package.json') }} | 
|  | 76 | +          restore-keys: | | 
|  | 77 | +            ${{ runner.os }}-node- | 
|  | 78 | +
 | 
|  | 79 | +      - name: install main | 
|  | 80 | +        run: npm ci --no-audit --no-fund | 
|  | 81 | +        working-directory: ./main | 
|  | 82 | +      - name: install project | 
|  | 83 | +        run: '[ -f package-lock.json ] && npm ci --force || npm install --force' | 
|  | 84 | +        working-directory: ./project | 
|  | 85 | +      - name: modify project eslint config | 
|  | 86 | +        run: sed 's/"@socketsecurity"/"..\/main\/test.eslintrc"/' .eslintrc > tmp.eslintrc && rm .eslintrc && mv tmp.eslintrc .eslintrc | 
|  | 87 | +        working-directory: ./project | 
|  | 88 | +      - name: modify project eslint config (ESM version) | 
|  | 89 | +        run: sed 's/"@socketsecurity\/eslint-config\/jsdoc"/"..\/main\/test-jsdoc.eslintrc"/' .eslintrc > tmp.eslintrc && rm .eslintrc && mv tmp.eslintrc .eslintrc | 
|  | 90 | +        working-directory: ./project | 
|  | 91 | +      - name: run eslint | 
|  | 92 | +        run: ../main/node_modules/.bin/eslint --resolve-plugins-relative-to ../main --ext js --ext cjs --ext mjs --report-unused-disable-directives . | 
|  | 93 | +        working-directory: ./project | 
0 commit comments