From c45d983d91d43dda5f084dc9a0058e7277c20661 Mon Sep 17 00:00:00 2001 From: eritque0arcus Date: Mon, 21 Aug 2023 18:14:07 -0400 Subject: [PATCH] feat: add noqa to skip specific platform, close #199 --- .github/workflows/cppBuilds.yml | 46 +++++++++++++++------------------ scripts/CIHelper.py | 44 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 scripts/CIHelper.py diff --git a/.github/workflows/cppBuilds.yml b/.github/workflows/cppBuilds.yml index 00b5646df..c8359715e 100644 --- a/.github/workflows/cppBuilds.yml +++ b/.github/workflows/cppBuilds.yml @@ -14,20 +14,23 @@ on: workflow_dispatch: jobs: + generated-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.generate-matrix.outputs.matrix }} + steps: + - name: checkout + uses: actions/checkout@v3 + - id: generate-matrix + run: python scripts/CIHelper.py genMatrix ${{ github.event.head_commit.message }} >> $GITHUB_OUTPUT + single: + needs: generated-matrix name: "build MiraiCP-single (${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: fail-fast: false - matrix: - os: - - windows-2019 - - ubuntu-20.04 - include: - - os: windows-2019 - targetName: MSVCX64 - - os: ubuntu-20.04 - targetName: LinuxX64 + matrix: ${{fromJson(needs.generated-matrix.outputs.matrix)}} env: isWindows: ${{ startsWith(matrix.os, 'windows') }} isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }} @@ -58,28 +61,21 @@ jobs: if: ${{ env.isWindows == 'true' }} run: ./scripts/WIN/cppBuilds.bat single - windows-mingw-single: - runs-on: windows-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - name: build with MinGW - run: ./scripts/WIN/cppBuilds.bat single mingw + # windows-mingw-single: + # runs-on: windows-latest + # steps: + # - name: checkout + # uses: actions/checkout@v3 + # - name: build with MinGW + # run: ./scripts/WIN/cppBuilds.bat single mingw libLoader: + needs: generated-matrix name: "build MiraiCP-libLoader (${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: fail-fast: false - matrix: - os: - - windows-2019 - - ubuntu-20.04 - include: - - os: windows-2019 - targetName: MSVCX64 - - os: ubuntu-20.04 - targetName: linuxX64 + matrix: ${{fromJson(needs.generated-matrix.outputs.matrix)}} env: isWindows: ${{ startsWith(matrix.os, 'windows') }} isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }} diff --git a/scripts/CIHelper.py b/scripts/CIHelper.py new file mode 100644 index 000000000..bfce8af1d --- /dev/null +++ b/scripts/CIHelper.py @@ -0,0 +1,44 @@ +# -*- utf-8 -*- +# author: eritque-arcus +# date: 08/21/23 + +import sys, json, regex + +def genMatrix(msg: str): + global winOS, linuxOS + matrix = { + "os":[winOS, linuxOS], + "include":[ + {"os": winOS, "targetName": "MSVCX64"}, + {"os": linuxOS, "targetName": "LinuxX64"} + ] + } + if msg.endswith("noqa"): + matrix = {"os": []} + else: + re = regex.findall(R"noqa\(([a-z,]+)\)$", msg)[0] + if re is not None: + OSs = re.split(',') + for OS in OSs: + if OS == "win" or OS == "windows": + matrix["os"].remove(winOS) + matrix["include"] = [item for item in matrix["include"] if item["os"] != winOS] + elif OS == "linux": + matrix["os"].remove(linuxOS) + matrix["include"] = [item for item in matrix["include"] if item["os"] != linuxOS] + else: + print("Error: Can't find specific noqa OS name:" + OS +"!!!!", file=sys.stderr) + print("matrix=" + json.dumps(matrix)) + +if __name__ == "__main__": + winOS = "windows-2019" + linuxOS = "ubuntu-20.04" + args = sys.argv + assert(len(args) >= 2) + cmd = args[1] + if cmd == "genMatrix": + assert(len(args) == 3) + genMatrix(args[2]) + else: + print("cmd not match!", file=sys.stderr) + exit(1) \ No newline at end of file