Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
feat: add noqa to skip specific platform, close #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Nambers committed Aug 21, 2023
1 parent d63fb96 commit c45d983
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 25 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/cppBuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down Expand Up @@ -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') }}
Expand Down
44 changes: 44 additions & 0 deletions scripts/CIHelper.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c45d983

Please sign in to comment.