Skip to content

Commit 0791037

Browse files
committed
Rework the GitHub Actions files.
- Use the new mithro/actions-includes for common functionality. - Refactor common functionality into their own include actions. Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
1 parent 1e5499f commit 0791037

File tree

18 files changed

+1836
-165
lines changed

18 files changed

+1836
-165
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
# Copyright (C) 2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
19
name: 🧰 Checkout
210
description: "Checkout the git repository correctly"
311

412
runs:
5-
using: "composite"
13+
using: "includes"
614

715
steps:
816
- name: 🧰 Checkout
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
9+
name: Download and run tests
10+
description: "Download the tests from GitHub and run them."
11+
12+
runs:
13+
using: "includes"
14+
15+
steps:
16+
17+
- name: Smoke Test - Run fasm tool
18+
run: |
19+
fasm --help
20+
21+
- name: Smoke Test - Import fasm module
22+
shell: python
23+
run: |
24+
import fasm
25+
26+
- name: Smoke Test - Print fasm version info
27+
includes-script: fasm-version.py
28+
29+
- name: Getting the tests
30+
includes-script: get-tests.sh
31+
32+
- name: List Tests
33+
shell: bash
34+
run: |
35+
echo "::group::Top directory"
36+
ls -l tests
37+
echo "::endgroup::"
38+
echo "::group::Files found"
39+
find tests -type f | sort
40+
echo "::endgroup::"
41+
42+
- name: Run Tests
43+
shell: bash
44+
run: |
45+
cd tests
46+
python test_simple.py
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
3+
import fasm.version
4+
5+
l = []
6+
7+
print()
8+
print(' FASM library version info')
9+
print('='*75)
10+
11+
kl = max(len(k) for k in dir(fasm.version))
12+
for k in dir(fasm.version):
13+
if '__' in k:
14+
continue
15+
v = getattr(fasm.version, k)
16+
if isinstance(v, str) and '\n' in v:
17+
l.append((k,v))
18+
else:
19+
print(" {!s}: {!r}".format(k.rjust(kl), v))
20+
21+
for k, v in l:
22+
print()
23+
print(k)
24+
print('-'*75)
25+
print(v)
26+
print('-'*75)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
if [ -d tests ]; then
2+
echo "::group::Using existing tests"
3+
ls -l tests
4+
echo "::endgroup::"
5+
else
6+
echo "::group::Event info"
7+
cat ${GITHUB_EVENT_PATH}
8+
echo "::endgroup::"
9+
echo "::group::GitHub info"
10+
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
11+
echo " GITHUB_ACTOR: ${GITHUB_ACTOR}"
12+
echo " GITHUB_REF: ${GITHUB_REF}"
13+
echo " GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
14+
echo " GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
15+
echo " GITHUB_SHA: ${GITHUB_SHA}"
16+
echo "::endgroup::"
17+
echo "::group::Downloading tests from ${GITHUB_REPOSITORY}"
18+
set -x
19+
mkdir .checkout-tests
20+
cd .checkout-tests
21+
git init
22+
git config core.sparseCheckout true
23+
if [ -f .git/info/sparse-checkout ]; then
24+
rm .git/info/sparse-checkout
25+
fi
26+
echo "tests/*" >> .git/info/sparse-checkout
27+
echo "examples/*" >> .git/info/sparse-checkout
28+
git remote add origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git
29+
git fetch --all
30+
git remote -v
31+
if [ ! -z "${GITHUB_REF}" ]; then
32+
git fetch --refmap='' origin ${GITHUB_REF}:refs/remotes/origin/merge || true
33+
fi
34+
if [ ! -z "${GITHUB_BASE_REF}" ]; then
35+
git fetch --refmap='' origin refs/heads/${GITHUB_BASE_REF}:refs/remotes/origin/base || true
36+
fi
37+
if [ ! -z "${GITHUB_HEAD_REF}" ]; then
38+
git fetch --refmap='' origin refs/heads/${GITHUB_HEAD_REF}:refs/remotes/origin/head || true
39+
fi
40+
git remote show origin
41+
git branch -v -a
42+
43+
git show-ref ${GITHUB_SHA} || true
44+
git rev-parse --verify "sha^${GITHUB_SHA}" || true
45+
46+
git fetch -q https://github.com/SymbiFlow/fasm.git ${GITHUB_SHA}
47+
git rev-parse FETCH_HEAD
48+
git checkout ${GITHUB_SHA}
49+
for i in *; do
50+
cp -rvf $i ..
51+
done
52+
cd ..
53+
echo "::endgroup::"
54+
fi

.github/workflows/system-setup/action.yaml renamed to .github/actions/system-setup/action.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Copyright (C) 2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
19
name: "Setup system for package"
210
description: "Set up system with Python environment and dependencies ready for the package."
311
inputs:
@@ -27,13 +35,13 @@ inputs:
2735
default: false
2836

2937
runs:
30-
using: "composite"
38+
using: "includes"
3139

3240
steps:
3341
- name: 🐍 Set up Python ${{ matrix.python-version }}
3442
uses: actions/setup-python@v2
3543
with:
36-
python-version: ${{ input.python-version }}
44+
python-version: ${{ inputs.python-version }}
3745

3846
- name: Install latest pip
3947
run: |
@@ -58,28 +66,28 @@ runs:
5866
- name: Install packaging tooling
5967
if: inputs.packaging-tools
6068
run: |
61-
pip install twine auditwheel
69+
pip install twine auditwheel build
6270
63-
- uses: ./.github/workflows/checkout
71+
- includes: /checkout
6472
if: inputs.git-checkout
6573

66-
- name: Install development system dependencies (Ubuntu)
74+
- name: Install developer tooling's system dependencies (Ubuntu)
6775
if: inputs.development-tools && startsWith(inputs.os, 'ubuntu')
6876
run: |
6977
sudo apt-get update
7078
sudo apt-get install -y clang-format
7179
72-
- name: Install development system dependencies (Mac OS X)
80+
- name: Install developer tooling's system dependencies (Mac OS X)
7381
if: inputs.development-tools && startsWith(inputs.os, 'macos')
7482
run: |
7583
true
7684
77-
- name: Install development system dependencies (Windows)
85+
- name: Install developer tooling's system dependencies (Windows)
7886
if: inputs.development-tools && startsWith(inputs.os, 'windows')
7987
run: |
8088
true
8189
82-
- name: Install development tooling
90+
- name: Install development tools
8391
if: inputs.development-tools
8492
run: |
8593
pip install -r requirements.txt
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (C) 2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
9+
name: "Publish packages into PyPI"
10+
description: "Check the packages and then publish packages onto Test and real versions."
11+
inputs:
12+
type:
13+
description: 'Type of packages to publish to PyPi.'
14+
required: true
15+
root_repo:
16+
description: 'Repository name that should be publishing packages to PyPi.'
17+
required: true
18+
root_branch:
19+
description: 'Default branch to publish packages from.'
20+
required: true
21+
default: refs/heads/master
22+
23+
runs:
24+
using: "includes"
25+
26+
steps:
27+
- name: ✔︎ Check 📦
28+
run: |
29+
for WHEEL in dist/*.whl; do
30+
echo
31+
echo "::group::Checking $WHEEL"
32+
echo
33+
python -m zipfile --list $WHEEL
34+
echo
35+
auditwheel show $WHEEL
36+
echo
37+
twine check $WHEEL
38+
echo
39+
echo "::endgroup::"
40+
done
41+
42+
- name: 📤 Publish ${{ inputs.type }} to Test PyPI
43+
env:
44+
TWINE_USERNAME: __token__
45+
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
46+
if: env.TWINE_PASSWORD != null
47+
run: |
48+
twine upload --skip-existing --verbose --repository testpypi dist/*
49+
50+
- name: 📤 Publish source to PyPI
51+
if: |
52+
(github.ref == inputs.root_branch) &&
53+
(github.event_name != 'pull_request') &&
54+
(github.repository == inputs.root_repo) &&
55+
env.TWINE_PASSWORD != null
56+
env:
57+
TWINE_USERNAME: __token__
58+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
59+
run: |
60+
twine upload dist/*

.github/workflows-src/Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2017-2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
9+
# Set up a Python environment to run the actions_include tool on.
10+
ENV_DIR = venv
11+
PYTHON = $(ENV_DIR)/bin/python3
12+
ACTIVATE = source $(ENV_DIR)/bin/activate;
13+
14+
env: requirements.txt
15+
rm -rf $(ENV_DIR)
16+
virtualenv --copies $(ENV_DIR)
17+
$(ACTIVATE) pip install -r $<
18+
touch --reference=$< $(PYTHON)
19+
20+
.PHONY: env
21+
22+
$(PYTHON): requirements.txt
23+
make env
24+
25+
# Generate the output files
26+
SRC_YAML = $(wildcard *.yml)
27+
OUT_YAML = $(addprefix ../workflows/,$(SRC_YAML))
28+
29+
../workflows/%.yml: %.yml | $(PYTHON)
30+
@echo
31+
@echo Updating $@
32+
@echo ------------------------------------------------
33+
$(ACTIVATE) python -m actions_includes $< $@
34+
@echo ------------------------------------------------
35+
36+
update:
37+
@for F in $(SRC_YAML); do touch $$F; done
38+
make build
39+
40+
build: $(OUT_YAML) | $(PYTHON)
41+
@true
42+
43+
info:
44+
@echo 'Output files: $(OUT_YAML)'
45+
46+
.PHONY: info
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (C) 2017-2021 The SymbiFlow Authors.
2+
#
3+
# Use of this source code is governed by a ISC-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/ISC
6+
#
7+
# SPDX-License-Identifier: ISC
8+
9+
on:
10+
push:
11+
pull_request:
12+
13+
name: Functionality
14+
jobs:
15+
16+
functionality:
17+
runs-on: ubuntu-20.04
18+
19+
strategy:
20+
matrix:
21+
antlr_runtime_type: [static, shared]
22+
include:
23+
- { python-version: 3.5, TOXENV: py35 }
24+
- { python-version: 3.6, TOXENV: py36 }
25+
- { python-version: 3.7, TOXENV: py37 }
26+
- { python-version: 3.8, TOXENV: py38 }
27+
- { python-version: 3.9, TOXENV: py39 }
28+
fail-fast: false
29+
30+
name: Functionality on Python ${{ matrix.python-version }} (with ${{ matrix.antlr_runtime_type}} antlr)
31+
32+
steps:
33+
- includes: /system-setup
34+
with:
35+
development-tools: true
36+
python-version: ${{ matrix.python-version }}
37+
38+
- name: Run Tests
39+
run: |
40+
ANTLR4_RUNTIME_TYPE=${{ matrix.antlr_runtime_type }} tox -e ${{ matrix.TOXENV }}

0 commit comments

Comments
 (0)