Skip to content

Commit

Permalink
Move CI workflow to common script, simplify packaging script, remove …
Browse files Browse the repository at this point in the history
…packing into a tarball since CI already packages artifacts into an archive

Internal-tag: [#57771]
Signed-off-by: Krzysztof Obłonczek <[email protected]>
  • Loading branch information
koblonczek committed May 9, 2024
1 parent 22ce47f commit ccf0adc
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 197 deletions.
10 changes: 10 additions & 0 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ examples:
paths:
- examples/**/build

package_cores:
stage: test
tags: ['ace-x86_64']
image: debian:bookworm
script:
- ./.github/scripts/ci.sh package_cores
artifacts:
paths:
- core_repo/**

build_docs:
image: $CI_DOCS_DOCKER_IMAGE
stage: build_docs
Expand Down
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exclude =
.eggs,
.git,
.gitignore,
.github,
.nox,
.pytest_cache,
__pycache__,
Expand Down
30 changes: 29 additions & 1 deletion .github/scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ generate_examples() {
done
}

package_cores() {
install_common_system_packages
begin_command_group "Install system packages for packaging cores"
log_cmd apt-get install -y --no-install-recommends python3-dev
end_command_group
enter_venv

begin_command_group "Install python packages for packaging cores"
log_cmd pip install git+https://github.com/antmicro/tuttest
end_command_group

install_topwrap

begin_command_group "Install Topwrap's parsing dependencies"
log_cmd pip install ".[topwrap-parse]"
end_command_group

begin_command_group "Package cores for release"
log_cmd mkdir core_repo
log_cmd pushd core_repo
log_cmd python ../.github/scripts/package_cores.py
log_cmd popd
end_command_group
}

case "$1" in
lint)
run_lint
Expand All @@ -144,7 +169,10 @@ tests)
examples)
generate_examples
;;
package_cores)
package_cores
;;
*)
echo "Usage: $0 {lint|tests|examples}"
echo "Usage: $0 {lint|tests|examples|package_cores}"
;;
esac
46 changes: 46 additions & 0 deletions .github/scripts/package_cores.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from pathlib import Path
from typing import List

from topwrap.repo.files import HttpGetFile
from topwrap.repo.user_repo import UserRepo, VerilogFileHandler


@dataclass
class RemoteRepo:
name: str
root_url: str
sources: List[str]


repos = [
RemoteRepo(
name="vexriscv",
root_url="https://raw.githubusercontent.com/litex-hub/pythondata-cpu-vexriscv/1979a644dbe64d8d32dfbdd970dccee6add63723/pythondata_cpu_vexriscv/verilog",
sources=[
"VexRiscv.v",
],
),
]


def package_cores():
"""Generates reusable cores package for usage in Topwrap project."""
core_repo = UserRepo()

for repo in repos:
core_files = []
for file in repo.sources:
core_files.append(HttpGetFile(f"{repo.root_url}/{file}"))

core_repo.add_files(VerilogFileHandler(core_files))

Path(repo.name).mkdir(exist_ok=True)
core_repo.save(repo.name)


if __name__ == "__main__":
package_cores()
36 changes: 0 additions & 36 deletions .github/workflows/cores.yml

This file was deleted.

26 changes: 25 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
runs-on: ubuntu-latest
container:
image: debian:bookworm
name: 'Generate examples'
name: "Generate examples"

steps:
- name: Install git package
Expand All @@ -72,3 +72,27 @@ jobs:
with:
name: examples
path: examples/**/build

package_cores:
runs-on: ubuntu-latest
container:
image: debian:bookworm
name: "Package cores repository"

steps:
- name: Install git package
run: |
apt-get update -qq
apt-get install -y git
- uses: actions/checkout@v4

- name: Pack cores into a Topwrap repository
run: |
./.github/scripts/ci.sh package_cores
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: core_repo
path: core_repo/**
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*.tar.gz

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
10 changes: 0 additions & 10 deletions docs/source/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,3 @@ To get help, use:
```
python -m topwrap [build|kpm_client|parse] --help
```

## Generating IP core archive

HDL sources can be packaged into a reusable tarball with autogenerated IP core description YAMLs:

```
python -m topwrap pack_core NAME SOURCE_DIRS
```

Where `NAME` is the name of target archive and `SOURCE_DIRS` is one or more directories with HDL files to be included in the package.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ exclude = '''
| \.eggs
| \.git
| \.gitignore
| \.github
| \.nox
| \.pytest_cache
| __pycache__
Expand All @@ -94,7 +93,6 @@ skip = [
".eggs",
".git",
".gitignore",
".github",
".nox",
".pytest_cache",
"__pycache__",
Expand Down
145 changes: 0 additions & 145 deletions scripts/pack_core.py

This file was deleted.

0 comments on commit ccf0adc

Please sign in to comment.