Skip to content

Commit e593591

Browse files
authored
Merge pull request #63 from krcb197/build_process_improvements
Build process improvements
2 parents 9da4439 + a37ca37 commit e593591

3 files changed

Lines changed: 67 additions & 13 deletions

File tree

.github/workflows/action.yaml

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
branches: [ main ]
1010
pull_request:
1111
branches: [ main ]
12+
schedule:
13+
- cron: '00 6 1 * *'
14+
release:
15+
types:
16+
- published
1217

1318
# Allows you to run this workflow manually from the Actions tab
1419
workflow_dispatch:
@@ -18,9 +23,9 @@ jobs:
1823
lint:
1924
runs-on: ubuntu-latest
2025
steps:
21-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2227
- name: Set up Python
23-
uses: actions/setup-python@v2
28+
uses: actions/setup-python@v4
2429
with:
2530
python-version: "3.10"
2631

@@ -36,9 +41,9 @@ jobs:
3641
mypy:
3742
runs-on: ubuntu-latest
3843
steps:
39-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v3
4045
- name: Set up Python
41-
uses: actions/setup-python@v2
46+
uses: actions/setup-python@v4
4247
with:
4348
python-version: "3.10"
4449

@@ -51,16 +56,19 @@ jobs:
5156
run: mypy src/peakrdl_python --config-file=tests/.mypy.ini
5257

5358
tests:
59+
needs:
60+
- mypy
61+
- lint
5462
runs-on: ubuntu-latest
5563
strategy:
5664
matrix:
5765
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
5866

5967
steps:
60-
- uses: actions/checkout@v2
68+
- uses: actions/checkout@v3
6169

6270
- name: Set up Python ${{ matrix.python-version }}
63-
uses: actions/setup-python@v2
71+
uses: actions/setup-python@v4
6472
with:
6573
python-version: ${{ matrix.python-version }}
6674

@@ -75,10 +83,13 @@ jobs:
7583
7684
- name: Generate testcases
7785
run: |
86+
# retrieve the example code from the systemRDL compiler
87+
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
7888
python generate_testcases.py
7989
mypy testcase_output/raw --config-file=tests/.mypy.ini
8090
# autopep8 is moving some of the #ignore statements around so it no longer passes mypy
8191
# mypy testcase_output/autopep8 --config-file=tests/.mypy.ini
92+
# pylint --rcfile tests/pylint.rc testcase_output/autopep8 --disable=duplicate-code,line-too-long,too-many-statements,invalid-name,unused-import,too-many-instance-attributes,too-many-arguments,too-many-lines
8293
pytest testcase_output/raw
8394
pytest testcase_output/autopep8
8495
@@ -113,4 +124,45 @@ jobs:
113124
# python -m flashing_the_LED
114125
115126
cd ../..
127+
#-------------------------------------------------------------------------------
128+
build_sdist:
129+
needs:
130+
- tests
131+
- lint
132+
- mypy
133+
name: Build source distribution
134+
runs-on: ubuntu-latest
135+
steps:
136+
- uses: actions/checkout@v3
137+
138+
- uses: actions/setup-python@v4
139+
name: Install Python
140+
with:
141+
python-version: 3.8
142+
143+
- name: Build sdist
144+
run: python setup.py sdist
145+
146+
- uses: actions/upload-artifact@v3
147+
with:
148+
path: dist/*.tar.gz
116149

150+
#-------------------------------------------------------------------------------
151+
deploy:
152+
needs:
153+
- build_sdist
154+
155+
runs-on: ubuntu-latest
156+
157+
# Only publish when a GitHub Release is created.
158+
if: github.event_name == 'release'
159+
steps:
160+
- uses: actions/download-artifact@v3
161+
with:
162+
name: artifact
163+
path: dist
164+
165+
- uses: pypa/gh-action-pypi-publish@master
166+
with:
167+
user: __token__
168+
password: ${{ secrets.PYPI_API_TOKEN }}

src/peakrdl_python/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
Variables that describes the PeakRDL Python Package
33
"""
4-
__version__ = "0.3.5"
4+
__version__ = "0.3.6"

src/peakrdl_python/exporter.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class PythonExporter:
3535
into the template namespace.
3636
"""
3737

38+
# pylint: disable=too-few-public-methods
39+
3840
def __init__(self, **kwargs):
3941

4042
user_template_dir = kwargs.pop("user_template_dir", None)
@@ -98,13 +100,13 @@ def export(self, node: Node, path: str,
98100
node = node.top
99101

100102
package_path = os.path.join(path, node.inst_name)
101-
self.create_empty_package(package_path=package_path)
103+
self._create_empty_package(package_path=package_path)
102104

103105
modules = [node]
104106

105107
for block in modules:
106108

107-
self.build_node_type_table(block)
109+
self._build_node_type_table(block)
108110

109111
context = {
110112
'print': print,
@@ -122,7 +124,7 @@ def export(self, node: Node, path: str,
122124
'isinstance': isinstance,
123125
'uses_enum' : uses_enum(block),
124126
'uses_memory' : uses_memory(block),
125-
'get_fully_qualified_type_name': self.lookup_type_name,
127+
'get_fully_qualified_type_name': self._lookup_type_name,
126128
'get_array_dim': get_array_dim,
127129
'get_dependent_component': get_dependent_component,
128130
'get_dependent_enum': get_dependent_enum,
@@ -168,7 +170,7 @@ def export(self, node: Node, path: str,
168170

169171
return [m.inst_name for m in modules]
170172

171-
def lookup_type_name(self, node: Node) -> str:
173+
def _lookup_type_name(self, node: Node) -> str:
172174
"""
173175
Retreive the unique type name from the current lookup list
174176
@@ -182,7 +184,7 @@ def lookup_type_name(self, node: Node) -> str:
182184

183185
return self.node_type_name[node.inst]
184186

185-
def build_node_type_table(self, node: AddressableNode) -> None:
187+
def _build_node_type_table(self, node: AddressableNode) -> None:
186188
"""
187189
Populate the type name lookup dictionary
188190
@@ -211,7 +213,7 @@ def build_node_type_table(self, node: AddressableNode) -> None:
211213
self.node_type_name[child_inst] = cand_type_name
212214

213215
@staticmethod
214-
def create_empty_package(package_path:str) -> None:
216+
def _create_empty_package(package_path:str) -> None:
215217
"""
216218
create the directories and __init__.py files associated with the exported package
217219

0 commit comments

Comments
 (0)