-
Notifications
You must be signed in to change notification settings - Fork 10
88 lines (72 loc) · 2.75 KB
/
build-ast.yml
File metadata and controls
88 lines (72 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Build Python Package
on:
workflow_call:
defaults:
run:
working-directory: source/openpulse
jobs:
build:
name: Build wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v3
# This is pure Python, so it shouldn't matter what version we use to
# build the sdist and wheel.
- name: Update pip
run: pip install --upgrade pip
- uses: actions/setup-java@v2
with:
java-version: '15'
distribution: 'adopt'
- name: Generate all ANTLR files
run: |
set -e
antlr_jar_dir="$PWD/.antlr_jars"
antlr_out_dir="$PWD/openpulse/_antlr"
mkdir -p "${antlr_jar_dir}"
mkdir -p "${antlr_out_dir}"
# Parse the full ANTLR versions we need. The 'sed' strips out
# comments from the file. We have to use `<<<` redirection rather
# than pipelining to avoid running in a subshell, which would prevent
# use from modifying the `antlr_versions` variable in the loop.
declare -a antlr_versions
while read -r line; do
if [ -n "$line" ]; then
antlr_versions+=("$line")
fi
done <<< $(sed 's/#.*//g' ANTLR_VERSIONS.txt);
# Download ANTLR.
pushd "${antlr_jar_dir}"
for version_string in "${antlr_versions[@]}"; do
curl -LO "https://www.antlr.org/download/antlr-${version_string}-complete.jar"
done
popd
# Build the ANTLR files.
pushd ${{ github.workspace }}/source/grammar
for version_string in "${antlr_versions[@]}"; do
echo "Handling version ${version_string}"
IFS=. read -ra version <<< "${version_string}"
out_dir="${antlr_out_dir}/_${version[0]}_${version[1]}"
mkdir -p "$out_dir"
java -Xmx500M -jar "${antlr_jar_dir}/antlr-${version_string}-complete.jar" -o "$out_dir" -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4
done
popd
# Replace version requirements in setup.cfg.
python tools/update_antlr_version_requirements.py setup.cfg ANTLR_VERSIONS.txt
- name: Install Python build dependencies
run: pip install --upgrade build
- name: Build package
run: python -m build --wheel --sdist .
- uses: actions/upload-artifact@v4
with:
name: openpulse-python-wheel
path: ./source/openpulse/dist/*.whl
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: openpulse-python-sdist
path: ./source/openpulse/dist/*.tar.gz
if-no-files-found: error