diff --git a/.github/workflows/E2E integration.yml b/.github/workflows/E2E integration.yml deleted file mode 100644 index eebaaf6..0000000 --- a/.github/workflows/E2E integration.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -name: E2E integration - -on: - push: - branches: [main] - pull_request_target: - branches: [main] - -env: - PROJECT: nodejs # The name of the project you want to clone. It must be on github - REPOSITORY: node # The repository name - FOLDER_TO_SCAN: lib # The folder under which the source code you have is contained. Relative to the repository - TS_CONFIG_PATH: tsconfig.json # The tsconfig.json path relative to the repository - -jobs: - build: - name: E2E run with sarif - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - - steps: - - name: Setup Node.js environment - uses: actions/setup-node@v4 - - - uses: actions/checkout@v4 - with: - repository: ${{env.PROJECT}}/${{env.REPOSITORY}} - path: ${{env.PROJECT}} - clean: true - - uses: actions/checkout@v4 - with: - path: eslint-plugin-sdl - clean: true - - # store them inside a seperate folder for performance in case of multiple projects. - # Trying to install eslint on a project with an existing package.json will install all of the package.json packages as well - - name: Create eslint directory - run: | - mkdir eslint - working-directory: ${{github.workspace}} - continue-on-error: true - - - name: Install eslint for discord library and eslint-plugin-dependencies - run: | - npm i eslint@8 - npm i eslint-plugin-security - npm i eslint-plugin-react - npm i eslint-plugin-node - npm i typescript - npm i @microsoft/eslint-formatter-sarif - working-directory: eslint - - - name: Link the eslint-plugin-sdl - run: | - sudo npm link ../eslint-plugin-sdl - working-directory: eslint - if: runner.os == 'Linux' - - - name: Link the eslint-plugin-sdl - run: | - npm link ../eslint-plugin-sdl - working-directory: eslint - if: runner.os == 'Windows' - - - name: Run eslint - run: npx eslint - -c node_modules/@microsoft/eslint-plugin-sdl/config/required.js - ../${{env.PROJECT}}/${{env.FOLDER_TO_SCAN}}/ - --ext .js - --parser-options=project:../${{env.PROJECT}}/${{env.TS_CONFIG_PATH}} - --no-eslintrc - -f @microsoft/eslint-formatter-sarif - -o ../${{env.PROJECT}}/eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif - working-directory: eslint - continue-on-error: true - - - name: Upload eslint results as artifact - uses: actions/upload-artifact@v4 - with: - name: eslint-result-${{ matrix.os }} - path: ${{env.PROJECT}}/eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif - if-no-files-found: error diff --git a/.github/workflows/e2e-integration.yml b/.github/workflows/e2e-integration.yml new file mode 100644 index 0000000..348e073 --- /dev/null +++ b/.github/workflows/e2e-integration.yml @@ -0,0 +1,87 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +name: E2E integration + +on: + push: + branches: [main, dev/martinkamar/eslint-v9] + pull_request_target: + branches: [main] + +env: + GITHUB_REPO: nodejs/node + GITHUB_REPO_ESLINT_GLOB: lib + GITHUB_REPO_TSCONFIG: tsconfig.json + TEST_TARGET_DIR: test-target + TEST_RUN_DIR: test-run + +jobs: + build: + name: E2E run with SARIF + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + + steps: + - name: Setup Node.js environment + uses: actions/setup-node@v4 + + - uses: actions/checkout@v4 + with: + repository: ${{env.GITHUB_REPO}} + path: ${{env.TEST_TARGET_DIR}} + clean: true + - uses: actions/checkout@v4 + with: + path: eslint-plugin-sdl + clean: true + + - name: Create test run directory + run: mkdir ${{env.TEST_RUN_DIR}} + working-directory: ${{github.workspace}} + continue-on-error: true + + - name: Install ESLint and eslint-plugin-sdl dependencies + run: | + npm i eslint + npm i eslint-plugin-security + npm i eslint-plugin-react + npm i eslint-plugin-node + npm i typescript + npm i @microsoft/eslint-formatter-sarif + working-directory: ${{env.TEST_RUN_DIR}} + + - name: Link eslint-plugin-sdl + run: sudo npm link ../eslint-plugin-sdl + working-directory: ${{env.TEST_RUN_DIR}} + if: runner.os == 'Linux' + + - name: Link eslint-plugin-sdl + run: npm link ../eslint-plugin-sdl + working-directory: ${{env.TEST_RUN_DIR}} + if: runner.os == 'Windows' + + - name: Copy ESLint config file + run: cp ../eslint-plugin-sdl/tests/fixtures/eslint.config.js . + working-directory: ${{env.TEST_RUN_DIR}} + + - name: Run ESLint + run: npx eslint + --config eslint.config.js + ../${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_ESLINT_GLOB}} + --parser-options=project:../${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_TSCONFIG}} + --no-config-lookup + --format @microsoft/eslint-formatter-sarif + --output-file ./eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif + working-directory: ${{env.TEST_RUN_DIR}} + continue-on-error: true + + - name: Upload ESLint results as artifact + uses: actions/upload-artifact@v4 + with: + name: eslint-result-${{ matrix.os }} + path: ${{env.TEST_RUN_DIR}}/eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif + if-no-files-found: error diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 53cee75..f179278 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,14 +8,11 @@ on: types: [created] jobs: - # Run one last check build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - with: - node-version: 22 - run: npm i - run: npm test @@ -26,7 +23,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 22 registry-url: https://registry.npmjs.org/ - run: npm i - run: npm publish diff --git a/tests/fixtures/eslint.config.js b/tests/fixtures/eslint.config.js new file mode 100644 index 0000000..54e8f74 --- /dev/null +++ b/tests/fixtures/eslint.config.js @@ -0,0 +1,5 @@ +const pluginMicrosoftSdl = require("@microsoft/eslint-plugin-sdl"); + +module.exports = [ + ...pluginMicrosoftSdl.configs.recommended +]; \ No newline at end of file