Tachiyomi-Extensions/.github/workflows/build_pull_request.yml

158 lines
5.1 KiB
YAML
Raw Normal View History

2021-02-01 22:51:54 +00:00
name: PR build check
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/workflows/issue_moderator.yml'
2021-02-01 22:51:54 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
2022-06-05 00:55:39 +00:00
env:
CI_CHUNK_SIZE: 65
2022-06-05 00:55:39 +00:00
2021-02-01 22:51:54 +00:00
jobs:
2022-06-05 00:55:39 +00:00
prepare:
name: Prepare job
2021-02-01 22:51:54 +00:00
runs-on: ubuntu-latest
2022-06-05 00:55:39 +00:00
outputs:
individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }}
multisrcMatrix: ${{ steps.generate-matrices.outputs.multisrcMatrix }}
isIndividualChanged: ${{ steps.parse-changed-files.outputs.isIndividualChanged }}
isMultisrcChanged: ${{ steps.parse-changed-files.outputs.isMultisrcChanged }}
2022-06-05 00:55:39 +00:00
env:
CI_MODULE_GEN: true
2021-02-01 22:51:54 +00:00
steps:
- name: Clone repo
uses: actions/checkout@v4
2021-02-01 22:51:54 +00:00
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
2022-06-05 00:55:39 +00:00
- name: Set up JDK
uses: actions/setup-java@v4
2022-06-05 00:55:39 +00:00
with:
2022-06-05 13:49:54 +00:00
java-version: 11
2022-06-05 00:55:39 +00:00
distribution: adopt
- id: get-changed-files
name: Get changed files
uses: Ana06/get-changed-files@v2.2.0
- id: parse-changed-files
name: Parse changed files
run: |
isIndividualChanged=0
isMultisrcChanged=0
for changedFile in ${{ steps.get-changed-files.outputs.all }}; do
if [[ ${changedFile} == src/* ]]; then
isIndividualChanged=1
elif [[ ${changedFile} == multisrc/* ]]; then
isMultisrcChanged=1
elif [[ ${changedFile} == .github/workflows/issue_moderator.yml ]]; then
true
elif [[ ${changedFile} == *.md ]]; then
true
else
isIndividualChanged=1
isMultisrcChanged=1
break
fi
done
echo "isIndividualChanged=$isIndividualChanged" >> $GITHUB_OUTPUT
echo "isMultisrcChanged=$isMultisrcChanged" >> $GITHUB_OUTPUT
2022-06-05 00:55:39 +00:00
- name: Generate multisrc sources
if: ${{ steps.parse-changed-files.outputs.isMultisrcChanged == '1' }}
uses: gradle/gradle-build-action@v2
2022-06-05 00:55:39 +00:00
with:
arguments: :multisrc:generateExtensions
- name: Get number of modules
run: |
set -x
./gradlew -q projects | grep '.*extensions\:\(individual\|multisrc\)\:.*\:.*' > projects.txt
echo "NUM_INDIVIDUAL_MODULES=$(cat projects.txt | grep '.*\:individual\:.*' | wc -l)" >> $GITHUB_ENV
echo "NUM_MULTISRC_MODULES=$(cat projects.txt | grep '.*\:multisrc\:.*' | wc -l)" >> $GITHUB_ENV
- id: generate-matrices
name: Create output matrices
uses: actions/github-script@v7
2022-06-05 00:55:39 +00:00
with:
script: |
const numIndividualModules = process.env.NUM_INDIVIDUAL_MODULES;
const numMultisrcModules = process.env.NUM_MULTISRC_MODULES;
const chunkSize = process.env.CI_CHUNK_SIZE;
const numIndividualChunks = Math.ceil(numIndividualModules / chunkSize);
const numMultisrcChunks = Math.ceil(numMultisrcModules / chunkSize);
console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`);
console.log(`Multi-source modules: ${numMultisrcModules} (${numMultisrcChunks} chunks of ${chunkSize})`);
core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] });
core.setOutput('multisrcMatrix', { 'chunk': [...Array(numMultisrcChunks).keys()] });
2021-02-13 00:05:45 +00:00
build_multisrc:
name: Build multisrc modules
2022-06-05 00:55:39 +00:00
needs: prepare
if: ${{ needs.prepare.outputs.isMultisrcChanged == '1' }}
2021-02-01 22:51:54 +00:00
runs-on: ubuntu-latest
2021-02-13 00:05:45 +00:00
strategy:
2022-06-05 00:55:39 +00:00
matrix: ${{ fromJSON(needs.prepare.outputs.multisrcMatrix) }}
2021-02-01 23:15:27 +00:00
steps:
2021-02-01 22:51:54 +00:00
- name: Checkout PR
uses: actions/checkout@v4
2021-02-01 22:51:54 +00:00
- name: Set up JDK
uses: actions/setup-java@v4
2021-02-01 22:51:54 +00:00
with:
2022-06-05 13:49:54 +00:00
java-version: 11
2022-05-15 17:56:52 +00:00
distribution: adopt
2021-02-01 22:51:54 +00:00
- name: Generate sources from the multi-source library
uses: gradle/gradle-build-action@v2
2021-02-13 00:05:45 +00:00
env:
2022-06-05 00:55:39 +00:00
CI_MODULE_GEN: "true"
with:
arguments: :multisrc:generateExtensions
2022-05-15 18:36:57 +00:00
cache-read-only: true
2022-06-05 00:55:39 +00:00
- name: Build extensions (chunk ${{ matrix.chunk }})
uses: gradle/gradle-build-action@v2
2021-02-13 00:05:45 +00:00
env:
CI_MULTISRC: "true"
2022-06-05 00:55:39 +00:00
CI_CHUNK_NUM: ${{ matrix.chunk }}
2021-02-01 22:51:54 +00:00
with:
arguments: assembleDebug
2022-05-15 18:36:57 +00:00
cache-read-only: true
2021-02-13 00:05:45 +00:00
build_individual:
name: Build individual modules
2022-06-05 00:55:39 +00:00
needs: prepare
if: ${{ needs.prepare.outputs.isIndividualChanged == '1' }}
2021-02-13 00:05:45 +00:00
runs-on: ubuntu-latest
strategy:
2022-06-05 00:55:39 +00:00
matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }}
2021-02-13 00:05:45 +00:00
steps:
- name: Checkout PR
uses: actions/checkout@v4
2021-02-13 00:05:45 +00:00
- name: Set up JDK
uses: actions/setup-java@v4
2021-02-13 00:05:45 +00:00
with:
2022-06-05 13:49:54 +00:00
java-version: 11
2022-05-15 17:56:52 +00:00
distribution: adopt
2021-02-13 00:05:45 +00:00
2022-06-05 00:55:39 +00:00
- name: Build extensions (chunk ${{ matrix.chunk }})
uses: gradle/gradle-build-action@v2
2021-02-13 00:05:45 +00:00
env:
CI_MULTISRC: "false"
2022-06-05 00:55:39 +00:00
CI_CHUNK_NUM: ${{ matrix.chunk }}
2021-02-13 00:05:45 +00:00
with:
arguments: assembleDebug
2022-05-15 18:36:57 +00:00
cache-read-only: true