From 92f1dc2a6c60ab7c43e07d3ef735a2f80fc127f7 Mon Sep 17 00:00:00 2001 From: n0099 Date: Thu, 13 Jun 2024 09:17:48 +0000 Subject: [PATCH] * move multiple values of `runs-on` into `matrix.runs-on` following https://stackoverflow.com/questions/75318609/matrix-strategy-over-entire-workflow-in-github-actions/75337311#75337311 @ .github/workflows --- .github/baseflows/be.yml | 59 +++++++++++++++++++++++++++++++++++++++ .github/baseflows/c#.yml | 57 ++++++++++++++++++++++++++++++++++++++ .github/baseflows/fe.yml | 35 +++++++++++++++++++++++ .github/workflows/be.yml | 60 ++++++---------------------------------- .github/workflows/c#.yml | 50 ++++----------------------------- .github/workflows/fe.yml | 36 ++++++------------------ 6 files changed, 174 insertions(+), 123 deletions(-) create mode 100644 .github/baseflows/be.yml create mode 100644 .github/baseflows/c#.yml create mode 100644 .github/baseflows/fe.yml diff --git a/.github/baseflows/be.yml b/.github/baseflows/be.yml new file mode 100644 index 00000000..11e5768f --- /dev/null +++ b/.github/baseflows/be.yml @@ -0,0 +1,59 @@ +name: be +on: + workflow_call: + inputs: + runs-on: + required: true + type: string +defaults: + run: + working-directory: be +jobs: + phpstan: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - run: ./vendor/bin/phpstan analyse --error-format=github + + psalm: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - run: ./vendor/bin/psalm --output-format=github + + phpcs: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - id: run + run: ./vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml . + - if: always() && steps.run.outcome == 'failure' + run: cs2pr ./phpcs-report.xml + + # https://github.com/staabm/annotate-pull-request-from-checkstyle + pint: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - id: run + run: ./vendor/bin/pint --test + - if: failure() && steps.run.outcome != 'success' + run: ./vendor/bin/pint --test --format=checkstyle | cs2pr + + php-cs-fixer: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - run: ./vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle . | cs2pr + + phpmd: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/be + - run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor # https://github.com/phpmd/phpmd/issues/506 diff --git a/.github/baseflows/c#.yml b/.github/baseflows/c#.yml new file mode 100644 index 00000000..6976a53a --- /dev/null +++ b/.github/baseflows/c#.yml @@ -0,0 +1,57 @@ +name: c# +on: + workflow_call: + inputs: + runs-on: + required: true + type: string +defaults: + run: + working-directory: c# +jobs: + build: + runs-on: ${{ inputs.runs-on }} + strategy: + matrix: + project: [crawler, imagePipeline, shared, tbClient] + fail-fast: false + env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/c# + - run: dotnet build --no-restore -c Release ${{ matrix.project }} + + ReSharper: + runs-on: ${{ inputs.runs-on }} + env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/c# + + - id: cache-restore + uses: actions/cache/restore@v4 + with: + path: | + ${{ github.workspace }}/.resharper + ~/.dotnet/tools + key: ${{ runner.os }}-resharper + restore-keys: ${{ runner.os }}-resharper- + + - uses: muno92/resharper_inspectcode@v1 + with: + version: 2024.* + minimumReportSeverity: info + minimumSeverity: warning + solutionPath: c#/tbm.sln + cachesHome: ${{ github.workspace }}/.resharper + + # https://github.com/actions/runner/issues/1478 + - uses: actions/cache/save@v4 + if: always() && steps.cache-restore.outputs.cache-hit != 'true' + with: + path: | + ${{ github.workspace }}/.resharper + ~/.dotnet/tools + key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/baseflows/fe.yml b/.github/baseflows/fe.yml new file mode 100644 index 00000000..a7a6a962 --- /dev/null +++ b/.github/baseflows/fe.yml @@ -0,0 +1,35 @@ +name: fe +on: + workflow_call: + inputs: + runs-on: + required: true + type: string +defaults: + run: + working-directory: fe +jobs: + tsc: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/fe + - run: yarn run vue-tsc + + eslint: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/fe + - run: yarn run eslint src + + codechecks: + runs-on: ${{ inputs.runs-on }} + steps: # contains CVE that triggers Dependabot + - uses: actions/checkout@v4 + - uses: ./.github/actions/fe + - run: | + yarn add -D typecov @codechecks/client + yarn run codechecks ../.github/codechecks.yml + env: + CC_SECRET: ${{ secrets.CC_SECRET }} diff --git a/.github/workflows/be.yml b/.github/workflows/be.yml index b4fb6169..0dfd140d 100644 --- a/.github/workflows/be.yml +++ b/.github/workflows/be.yml @@ -1,56 +1,14 @@ +# https://stackoverflow.com/questions/75318609/matrix-strategy-over-entire-workflow-in-github-actions/75337311#75337311 name: be on: push: paths: [be/**] -defaults: - run: - working-directory: be jobs: - phpstan: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - run: ./vendor/bin/phpstan analyse --error-format=github - - psalm: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - run: ./vendor/bin/psalm --output-format=github - - phpcs: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - id: run - run: ./vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml . - - if: always() && steps.run.outcome == 'failure' - run: cs2pr ./phpcs-report.xml - - # https://github.com/staabm/annotate-pull-request-from-checkstyle - pint: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - id: run - run: ./vendor/bin/pint --test - - if: failure() && steps.run.outcome != 'success' - run: ./vendor/bin/pint --test --format=checkstyle | cs2pr - - php-cs-fixer: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - run: ./vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle . | cs2pr - - phpmd: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/be - - run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor # https://github.com/phpmd/phpmd/issues/506 + build: + strategy: + matrix: + runs-on: [ubuntu-latest, windows-latest, macos-latest] + fail-fast: false + uses: ./.github/baseflows/be.yml + with: + runs-on: ${{ matrix.runs-on }} diff --git a/.github/workflows/c#.yml b/.github/workflows/c#.yml index 72d88e56..5469e323 100644 --- a/.github/workflows/c#.yml +++ b/.github/workflows/c#.yml @@ -1,54 +1,14 @@ +# https://stackoverflow.com/questions/75318609/matrix-strategy-over-entire-workflow-in-github-actions/75337311#75337311 name: c# on: push: paths: [c#/**] -defaults: - run: - working-directory: c# jobs: build: - runs-on: [ubuntu-latest, windows-latest, macos-latest] strategy: matrix: - project: [crawler, imagePipeline, shared, tbClient] + runs-on: [ubuntu-latest, windows-latest, macos-latest] fail-fast: false - env: - NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/c# - - run: dotnet build --no-restore -c Release ${{ matrix.project }} - - ReSharper: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - env: - NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/c# - - - id: cache-restore - uses: actions/cache/restore@v4 - with: - path: | - ${{ github.workspace }}/.resharper - ~/.dotnet/tools - key: ${{ runner.os }}-resharper - restore-keys: ${{ runner.os }}-resharper- - - - uses: muno92/resharper_inspectcode@v1 - with: - version: 2024.* - minimumReportSeverity: info - minimumSeverity: warning - solutionPath: c#/tbm.sln - cachesHome: ${{ github.workspace }}/.resharper - - # https://github.com/actions/runner/issues/1478 - - uses: actions/cache/save@v4 - if: always() && steps.cache-restore.outputs.cache-hit != 'true' - with: - path: | - ${{ github.workspace }}/.resharper - ~/.dotnet/tools - key: ${{ steps.cache-restore.outputs.cache-primary-key }} + uses: ./.github/baseflows/c#.yml + with: + runs-on: ${{ matrix.runs-on }} diff --git a/.github/workflows/fe.yml b/.github/workflows/fe.yml index b007ff28..0b8d560d 100644 --- a/.github/workflows/fe.yml +++ b/.github/workflows/fe.yml @@ -1,32 +1,14 @@ +# https://stackoverflow.com/questions/75318609/matrix-strategy-over-entire-workflow-in-github-actions/75337311#75337311 name: fe on: push: paths: [fe/**] -defaults: - run: - working-directory: fe jobs: - tsc: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/fe - - run: yarn run vue-tsc - - eslint: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/fe - - run: yarn run eslint src - - codechecks: - runs-on: [ubuntu-latest, windows-latest, macos-latest] - steps: # contains CVE that triggers Dependabot - - uses: actions/checkout@v4 - - uses: ./.github/actions/fe - - run: | - yarn add -D typecov @codechecks/client - yarn run codechecks ../.github/codechecks.yml - env: - CC_SECRET: ${{ secrets.CC_SECRET }} + build: + strategy: + matrix: + runs-on: [ubuntu-latest, windows-latest, macos-latest] + fail-fast: false + uses: ./.github/baseflows/fe.yml + with: + runs-on: ${{ matrix.runs-on }}