From 196bbd8094d0628bf182a583d972ae50b3c4a260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Sat, 17 Feb 2024 12:57:20 +0100 Subject: [PATCH] Fixes CI Badge in README.md (#164) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes CI Badge in README.md * Removes additional fetching from git * More work on the CI script * Adds requirements.txt for tools, fixes CI script even more --------- Co-authored-by: Felix "xq" Queißner --- .github/workflows/build.yml | 20 ++++---------------- .github/workflows/deploy.yml | 10 ++-------- README.md | 2 +- tools/bundle.py | 8 ++++++-- tools/lib/common.py | 4 ++-- tools/requirements.txt | 5 +++++ 6 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 tools/requirements.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 929e54d..e00945d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,13 +19,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true # required for "git describe" - - - name: Fetch more data from git - run: | - # fetch everything back till the $(ZIG_VERSION) tag. - # https://stackoverflow.com/a/58082274 - git fetch --shallow-exclude ${{ env.ZIG_VERSION }} - git fetch --deepen=2 + fetch-depth: 0 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 @@ -34,7 +28,7 @@ jobs: - name: Install PIP packages run: | - pip install dataclasses_json==0.6.3 marshmallow typing-inspect semver pathspec + pip install -r tools/requirements.txt - name: Generate and validate packages run: | @@ -53,13 +47,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true # required for "git describe" - - - name: Fetch more data from git - run: | - # fetch everything back till the $(ZIG_VERSION) tag. - # https://stackoverflow.com/a/58082274 - git fetch --shallow-exclude ${{ env.ZIG_VERSION }} - git fetch --deepen=2 + fetch-depth: 0 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 @@ -68,7 +56,7 @@ jobs: - name: Install PIP packages run: | - pip install dataclasses_json==0.6.3 marshmallow typing-inspect semver pathspec + pip install -r tools/requirements.txt - name: Generate packages run: | diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fc174c0..e2a30df 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,13 +16,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true # required for "git describe" - - - name: Fetch more data from git - run: | - # fetch everything back till the $(ZIG_VERSION) tag. - # https://stackoverflow.com/a/58082274 - git fetch --shallow-exclude ${{ env.ZIG_VERSION }} - git fetch --deepen=2 + fetch-depth: 0 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 @@ -31,7 +25,7 @@ jobs: - name: Install PIP packages run: | - pip install dataclasses_json==0.6.3 marshmallow typing-inspect semver pathspec + pip install -r tools/requirements.txt - name: Generate and validate packages run: | diff --git a/README.md b/README.md index f0c7c1e..446f205 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Chat](https://img.shields.io/discord/824493524413710336.svg?logo=discord)](link=https://discord.gg/ShUWykk38X) [![Downloads](https://img.shields.io/badge/Zig_Package-Download-blue)](https://downloads.microzig.tech/) -[![Continuous Integration](https://github.com/ZigEmbeddedGroup/microzig-monorepo/actions/workflows/build.yml/badge.svg)](https://github.com/ZigEmbeddedGroup/microzig-monorepo/actions/workflows/build.yml) +[![Continuous Integration](https://github.com/ZigEmbeddedGroup/microzig/actions/workflows/build.yml/badge.svg)](https://github.com/ZigEmbeddedGroup/microzig/actions/workflows/build.yml) > **NOTE:** This is in development; breaks in the API are bound to happen. diff --git a/tools/bundle.py b/tools/bundle.py index a70081c..b4c0d78 100755 --- a/tools/bundle.py +++ b/tools/bundle.py @@ -38,6 +38,7 @@ REQUIRED_TOOLS = [ "zig", "git", ] +REQUIRED_ZIG_VERSION="0.11.0" REPO_ROOT = Path(__file__).parent.parent @@ -168,7 +169,10 @@ def build_zig_tools(): # Determines the correct version: def get_version_from_git() -> str: - raw_git_out = slurp("git", "describe", "--match", "*.*.*", "--tags", "--abbrev=9", cwd=REPO_ROOT).strip().decode() + raw_git_out = slurp("git", "describe", "--match", "*.*.*", "--tags", "--abbrev=9", cwd=REPO_ROOT, allow_failure=True).strip().decode() + if len(raw_git_out) == 0: + print("failed to get version from git, using 'development'", file=sys.stderr) + return f"{REQUIRED_ZIG_VERSION}-development" def render_version(major,minor,patch,counter,hash): return f"{major}.{minor}.{patch}-{counter}-{hash}" @@ -251,7 +255,7 @@ def main(): check_required_tools(REQUIRED_TOOLS) - check_zig_version("0.11.0") + check_zig_version(REQUIRED_ZIG_VERSION) print("preparing environment...") diff --git a/tools/lib/common.py b/tools/lib/common.py index 4d72ca9..b0bb984 100644 --- a/tools/lib/common.py +++ b/tools/lib/common.py @@ -3,14 +3,14 @@ import subprocess, sys VERBOSE = False -def execute_raw(*args,hide_stderr = False,**kwargs): +def execute_raw(*args,hide_stderr: bool = False, allow_failure: bool = False, **kwargs): args = [ str(f) for f in args] if VERBOSE: print(*args) res = subprocess.run(args, **kwargs, check=False) if res.stderr is not None and (not hide_stderr or res.returncode != 0): sys.stderr.buffer.write(res.stderr) - if res.returncode != 0: + if not allow_failure and res.returncode != 0: sys.stderr.write(f"command {' '.join(args)} failed with exit code {res.returncode}") sys.exit(res.returncode) return res diff --git a/tools/requirements.txt b/tools/requirements.txt new file mode 100644 index 0000000..b43b94f --- /dev/null +++ b/tools/requirements.txt @@ -0,0 +1,5 @@ +dataclasses_json==0.6.3 +marshmallow +typing-inspect +semver +pathspec