From d609d97d555ce10dbb44a32f84775a969675fde5 Mon Sep 17 00:00:00 2001 From: windowsboy111 Date: Thu, 16 Mar 2023 19:22:07 +0800 Subject: [PATCH] feat(ci): improve mass-rebuild workflow --- .github/workflows/mass-rebuild-recurse.yml | 86 ++++++++++++++++++++++ .github/workflows/mass-rebuild.yml | 22 +++++- 2 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/mass-rebuild-recurse.yml diff --git a/.github/workflows/mass-rebuild-recurse.yml b/.github/workflows/mass-rebuild-recurse.yml new file mode 100644 index 0000000000..3e8d2976e6 --- /dev/null +++ b/.github/workflows/mass-rebuild-recurse.yml @@ -0,0 +1,86 @@ +# for each folder in anda/ +# generate a new workflow for each folder in anda/ +name: Mass Rebuild +on: + workflow_dispatch: + inputs: + packages: + description: Packages to Build (JSON) + required: true + +jobs: + manifest: + runs-on: ubuntu-latest + + outputs: + build_matrix: ${{ steps.generate_build_matrix.outputs.build_matrix }} + + container: + image: ghcr.io/terrapkg/builder:main + options: --cap-add=SYS_ADMIN --privileged + + steps: + - name: Generate Build matrix + id: generate_build_matrix + run: | + echo "build_matrix=${{ inputs.packages }}" > x.py + cat < x.py + import json + if len(build_matrix) > 255: + print("recurse=1") + print(f"build_matrix={json.dumps(build_matrix[:256])}") + print(f"recurse_matrix={json.dumps(build_matrix[256:])}") + else: + print("recurse=0") + print(f"build_matrix={json.dumps(build_matrix)}") + print("recurse_matrix=[]") + EOF + python x.py >> $GITHUB_OUTPUT + + - name: Recurse builds + if: steps.generate_build_matrix.outputs.recurse == 1 + uses: terrapkg/packages/.github/workflows/mass-rebuild-recurse.yml@f38 + with: + packages: ${{ steps.generate_build_matrix.outputs.recurse_matrix }} + build: + needs: manifest + strategy: + matrix: + pkg: ${{ fromJson(needs.manifest.outputs.build_matrix) }} + version: ["38"] + arch: ["x86_64", "aarch64"] + fail-fast: false + #if: ${{ matrix.changed_folders != '' }} + runs-on: ${{ matrix.arch == 'aarch64' && 'ARM64' || 'ubuntu-latest' }} + container: + image: ghcr.io/terrapkg/builder:f38 + options: --cap-add=SYS_ADMIN --privileged + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Check file existence + id: check_files + run: | + if test -f "${{ matrix.pkg }}anda.hcl"; then + echo "EXISTS=true" >> $GITHUB_OUTPUT + else + echo "EXISTS=false" >> $GITHUB_OUTPUT + fi + + - uses: terrapkg/anda-build@main + if: steps.check_files.outputs.EXISTS == 'true' + with: + name: "${{ matrix.pkg }}pkg" + mockConfig: anda-${{ matrix.version }}-${{ matrix.arch }} + extraArgs: -D "sccache_bucket ${{secrets.SCCACHE_BUCKET}}" -D "sccache_endpoint ${{secrets.SCCACHE_ENDPOINT}}" -D "sccache_secret ${{secrets.SCCACHE_SECRET}}" -D "sccache_accesskey ${{secrets.SCCACHE_ACCESSKEY}}" + andaRepo: https://github.com/terrapkg/subatomic-repos/raw/main/terra.repo + + - name: Upload packages to subatomic + if: steps.check_files.outputs.EXISTS == 'true' + run: | + subatomic-cli upload --prune \ + --server https://subatomic.fyralabs.com \ + --token ${{ secrets.SUBATOMIC_TOKEN }} \ + terra${{ matrix.version }} anda-build/rpm/rpms/* diff --git a/.github/workflows/mass-rebuild.yml b/.github/workflows/mass-rebuild.yml index 4c8cbb555d..2967c75e12 100644 --- a/.github/workflows/mass-rebuild.yml +++ b/.github/workflows/mass-rebuild.yml @@ -27,7 +27,25 @@ jobs: run: | git checkout -b mass-rebuild $(git rev-list HEAD | tail -n 1) git merge --squash $(git branch --show-current) - anda ci >> $GITHUB_OUTPUT + anda ci > x.py + cat < x.py + import json + if len(build_matrix) > 255: + print("recurse=1") + print(f"build_matrix={json.dumps(build_matrix[:256])}") + print(f"recurse_matrix={json.dumps(build_matrix[256:])}") + else: + print("recurse=0") + print(f"build_matrix={json.dumps(build_matrix)}") + print("recurse_matrix=[]") + EOF + python x.py >> $GITHUB_OUTPUT + + - name: Recurse builds + if: steps.generate_build_matrix.outputs.recurse == 1 + uses: terrapkg/packages/.github/workflows/mass-rebuild-recurse.yml@f38 + with: + packages: ${{ steps.generate_build_matrix.outputs.recurse_matrix }} build: needs: manifest strategy: @@ -39,7 +57,7 @@ jobs: #if: ${{ matrix.changed_folders != '' }} runs-on: ${{ matrix.arch == 'aarch64' && 'ARM64' || 'ubuntu-latest' }} container: - image: ghcr.io/terrapkg/builder:main + image: ghcr.io/terrapkg/builder:f38 options: --cap-add=SYS_ADMIN --privileged steps: - name: Checkout