Skip to content

Commit

Permalink
Fixes CI Badge in README.md (#164)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ikskuh and Felix "xq" Queißner authored Feb 17, 2024
1 parent 829f860 commit 196bbd8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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: |
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions tools/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"zig",
"git",
]
REQUIRED_ZIG_VERSION="0.11.0"


REPO_ROOT = Path(__file__).parent.parent
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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...")

Expand Down
4 changes: 2 additions & 2 deletions tools/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

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
Expand Down
5 changes: 5 additions & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dataclasses_json==0.6.3
marshmallow
typing-inspect
semver
pathspec

0 comments on commit 196bbd8

Please sign in to comment.