From 3a56bfdc516bcc2fd71a4590b2cf9571ce5cfb39 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Mon, 15 May 2023 10:58:53 +0200 Subject: [PATCH] ci: replace custom lint workflow with org templates Signed-off-by: Richard Steinmetz --- .../workflows/lint-eslint-when-unrelated.yml | 39 +++++++++++ .github/workflows/lint-eslint.yml | 62 ++++++++++++++++++ .github/workflows/lint-info-xml.yml | 39 +++++++++++ .github/workflows/lint-php-cs.yml | 40 ++++++++++++ .github/workflows/lint-php.yml | 60 +++++++++++++++++ .github/workflows/lint.yml | 65 ------------------- 6 files changed, 240 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/lint-eslint-when-unrelated.yml create mode 100644 .github/workflows/lint-eslint.yml create mode 100644 .github/workflows/lint-info-xml.yml create mode 100644 .github/workflows/lint-php-cs.yml create mode 100644 .github/workflows/lint-php.yml delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint-eslint-when-unrelated.yml b/.github/workflows/lint-eslint-when-unrelated.yml new file mode 100644 index 00000000..7a2e9f05 --- /dev/null +++ b/.github/workflows/lint-eslint-when-unrelated.yml @@ -0,0 +1,39 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks + +name: Lint eslint + +on: + pull_request: + paths-ignore: + - '.github/workflows/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' + - '**.js' + - '**.ts' + - '**.vue' + +permissions: + contents: read + +jobs: + lint: + permissions: + contents: none + + runs-on: ubuntu-latest + + name: eslint + + steps: + - run: 'echo "No eslint required"' diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml new file mode 100644 index 00000000..edcd1e81 --- /dev/null +++ b/.github/workflows/lint-eslint.yml @@ -0,0 +1,62 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks + +name: Lint eslint + +on: + pull_request: + paths: + - '.github/workflows/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' + - '**.js' + - '**.ts' + - '**.vue' + +permissions: + contents: read + +concurrency: + group: lint-eslint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + name: eslint + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 + id: versions + with: + fallbackNode: '^16' + fallbackNpm: '^7' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml new file mode 100644 index 00000000..a1b6ec59 --- /dev/null +++ b/.github/workflows/lint-info-xml.yml @@ -0,0 +1,39 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint info.xml + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: lint-info-xml-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + xml-linters: + runs-on: ubuntu-latest + + name: info.xml lint + steps: + - name: Checkout + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Download schema + run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd + + - name: Lint info.xml + uses: ChristophWurst/xmllint-action@39155a91429af431d65fafc21fa52ba5c4f5cb71 # v1.1 + with: + xml-file: ./appinfo/info.xml + xml-schema-file: ./info.xsd diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml new file mode 100644 index 00000000..e581270a --- /dev/null +++ b/.github/workflows/lint-php-cs.yml @@ -0,0 +1,40 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint php-cs + +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-php-cs-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + name: php-cs + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + + - name: Set up php + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 + with: + php-version: 8.1 + coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: composer i + + - name: Lint + run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml new file mode 100644 index 00000000..3bcfaaa8 --- /dev/null +++ b/.github/workflows/lint-php.yml @@ -0,0 +1,60 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint php + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: lint-php-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: [ "8.0", "8.1", "8.2" ] + + name: php-lint + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Lint + run: composer run lint + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: php-lint + + if: always() + + name: php-lint-summary + + steps: + - name: Summary status + run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 60762b9d..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Lint -on: pull_request - -jobs: - xml-linters: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - name: Download schema - run: wget https://apps.nextcloud.com/schema/apps/info.xsd - - name: Lint info.xml - uses: ChristophWurst/xmllint-action@v1 - with: - xml-file: ./appinfo/info.xml - xml-schema-file: ./info.xsd - - php-linters: - runs-on: ubuntu-latest - strategy: - matrix: - php-versions: ['7.4', '8.0', '8.1', '8.2'] - name: php${{ matrix.php-versions }} lint - steps: - - name: Checkout - uses: actions/checkout@master - - name: Set up php${{ matrix.php-versions }} - uses: shivammathur/setup-php@master - with: - php-version: ${{ matrix.php-versions }} - coverage: none - - name: Lint - run: composer run lint - - php-cs-fixer: - name: php-cs check - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - name: Set up php - uses: shivammathur/setup-php@master - with: - php-version: 8.0 - coverage: none - - name: Install dependencies - run: composer i - - name: Run coding standards check - run: composer run cs:check - - node-linters: - runs-on: ubuntu-latest - name: ESLint - steps: - - uses: actions/checkout@master - - name: Set up Node - uses: actions/setup-node@v2.5.0 - with: - node-version: 16.x - - name: npm install - run: npm ci - - name: eslint - run: npm run lint - env: - CI: true