Skip to content

.github: create test workflow #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8a9ac1f
.github: create test workflow
davidmalcolm Sep 20, 2020
60ed103
.github/workflows/test.yml: matrix experiment
davidmalcolm Sep 20, 2020
3b4a209
.github/workflows/test.yml: fix yaml
davidmalcolm Sep 20, 2020
9273ee6
.github/workflows/test.yml: fix missing 'run' key
davidmalcolm Sep 20, 2020
bec1989
.github/workflows/test.yml: puth 'matrix' inside a 'strategy'
davidmalcolm Sep 20, 2020
f0e9354
.github/workflows/test.yml: set CC and CXX
davidmalcolm Sep 20, 2020
8045242
.github/workflows/test.yml: more GCC versions
davidmalcolm Sep 20, 2020
5812d88
.github/workflows/test.yml: drop 4.8 and 4.9 for now; try to use diff…
davidmalcolm Sep 20, 2020
3ac280a
.github/workflows/test.yml: fix yaml
davidmalcolm Sep 20, 2020
22de1ae
.github/workflows/test.yml: do gcc first; try to install python deps
davidmalcolm Sep 20, 2020
234b63d
.github/workflows/test.yml: test python-config
davidmalcolm Sep 20, 2020
72d6998
run-test-suite.py: don't assume python headers are in /usr/include/
davidmalcolm Sep 20, 2020
f3e638e
run-test-suite.py: fixup to don't assume python headers are in /usr/i…
davidmalcolm Sep 20, 2020
0062d0e
.github/workflows/test.yml: try to set PYTHON_CONFIG for python 3
davidmalcolm Sep 20, 2020
a954335
.github/workflows/test.yml: pass any PYTHON_CONFIG for python 3 to Ma…
davidmalcolm Sep 20, 2020
7c34515
.github/workflows/test.yml: set default PYTHON_CONFIG
davidmalcolm Sep 20, 2020
3d5690a
Undo 4deefc840e69e3c2c42f8a50963b8fb69c17efee to try to fix build on …
davidmalcolm Sep 20, 2020
13a5ade
.github/workflows/test.yml: attempt to debug PYTHON_CONFIG
davidmalcolm Sep 20, 2020
e45236b
.github/workflows/test.yml: fix name of Python installation step
davidmalcolm Sep 20, 2020
539322e
Makefile: add python-config's --ldflags to the link
davidmalcolm Sep 20, 2020
a6ef36b
Makefile: omit testdemo for now
davidmalcolm Sep 20, 2020
e38864c
.github/workflows/test.yml: try to set LD_LIBRARY_PATH
davidmalcolm Sep 20, 2020
280f59c
.github/workflows/test.yml: fix LD_LIBRARY_PATH access
davidmalcolm Sep 20, 2020
bbd1105
run-test-suite.py: exclude absinterp tests for GCC 6 as well as GCC 7…
davidmalcolm Sep 20, 2020
2fa41bd
run-test-suite.py: exclude absinterp tests for GCC 5 as well as GCC 6…
davidmalcolm Sep 20, 2020
fa8a512
run-test-suite.py: use configparser.ConfigParser rather than configpa…
davidmalcolm Sep 20, 2020
f342f84
run-test-suite.py: skip tests/plugin/namespace on Python >= 3.7
davidmalcolm Sep 20, 2020
cd57097
Reinstate 4deefc840e69e3c2c42f8a50963b8fb69c17efee
davidmalcolm Sep 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
name: Python ${{ matrix.python-version }} and GCC ${{ matrix.gcc-version }}
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
gcc-version: [5, 6, 7, 8, 9, 10]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up GCC ${{ matrix.gcc-version }}
run: sudo apt-get install g++-${{matrix.gcc-version}} gcc-${{matrix.gcc-version}}-plugin-dev

- name: Display GCC version
run: gcc-${{matrix.gcc-version}} --version

# https://docs.github.com/en/actions/guides/building-and-testing-python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: |
python -c "import sys; print(sys.version)"
python-config --cflags
python3-config --cflags
python-config --libs
python3-config --libs

- name: Install Python dependencies
run: python -m pip install --upgrade six pygments lxml

- name: Build plugin and run the testsuite
run: |
export CC=gcc-${{matrix.gcc-version}}
export CXX=g++-${{matrix.gcc-version}}
if [ $(python -c"import sys; print(sys.version_info.major)") = "3" ]
then
export PYTHON_CONFIG=python3-config
else
export PYTHON_CONFIG=python-config
fi
$PYTHON_CONFIG --cflags
$PYTHON_CONFIG --libs
# Try to extract "-Lpath" from python-config --ldflags and add
# it to LD_LIBRARY_PATH
LD_LIBRARY_PATH=$(echo $($PYTHON_CONFIG --ldflags) | grep -o "\-L\S*" | cut -c 3-):$LD_LIBRARY_PATH
echo LD_LIBRARY_PATH: $LD_LIBRARY_PATH
pwd=$(pwd -P)
mkdir build
cd build
make -f $pwd/Makefile srcdir=$pwd/ PYTHON_CONFIG=$PYTHON_CONFIG LD_LIBRARY_PATH=$LD_LIBRARY_PATH
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ PYTHON_CONFIG=python-config

PYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes)
PYTHON_LIBS=$(shell $(PYTHON) -c 'import sys;print("-lpython%d.%d" % sys.version_info[:2])') $(shell $(PYTHON_CONFIG) --libs)
PYTHON_LDFLAGS=$(shell $(PYTHON_CONFIG) --ldflags)

# Support having multiple named plugins
# e.g. "python2.7" "python3.2mu" "python 3.2dmu" etc:
Expand Down Expand Up @@ -152,6 +153,7 @@ $(PLUGIN_DSO): $(PLUGIN_OBJECT_FILES) $(LIBGCC_C_API_SO)
$(PLUGIN_OBJECT_FILES) \
-o $@ \
$(LIBS) \
$(PYTHON_LDFLAGS) \
-lgcc-c-api -Lgcc-c-api -Wl,-rpath=$(GCCPLUGINS_DIR)

$(pwd)/gcc-c-api:
Expand Down Expand Up @@ -322,7 +324,7 @@ testdemo: plugin print-gcc-version
json-examples: plugin
$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-cpychecker -I/usr/include/python2.7 -c libcpychecker_html/test/example1/bug.c

test-suite: plugin print-gcc-version testdejagnu testdemo
test-suite: plugin print-gcc-version testdejagnu
$(INVOCATION_ENV_VARS) $(PYTHON) $(srcdir)./run-test-suite.py $(if $(srcdir),--srcdir=$(srcdir))

show-ssa: plugin
Expand Down
15 changes: 10 additions & 5 deletions run-test-suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ def _cleanup(self, text):
# e.g.
# unknown struct PyObject * from /usr/include/python2.7/pyerrors.h:135
# unknown struct PyObject * from /usr/include/python3.2mu/pyerrors.h:132
# should both become:
# unknown struct PyObject * from /opt/hostedtoolcache/Python/2.7.18/x64/include/python2.7/pyerrors.h:141
# should all become:
# unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn
line = re.sub('/usr/include/python(.*)/(.*).h:[0-9]+',
r'/usr/include/python?.?/\2.h:nn',
line = re.sub('/(\S+)/include/python(.*)/(.*).h:[0-9]+',
r'/usr/include/python?.?/\3.h:nn',
line)

# Convert to the Python 3 format for the repr() of a frozenset:
Expand Down Expand Up @@ -286,7 +287,7 @@ def run_test(testdir, srcdir):
out = TestStream(os.path.join(testdir, 'stdout.txt'), srcdir)
err = TestStream(os.path.join(testdir, 'stderr.txt'), srcdir)

cp = configparser.SafeConfigParser()
cp = configparser.ConfigParser()
metadatapath = os.path.join(testdir, 'metadata.ini')
cp.read([metadatapath])

Expand Down Expand Up @@ -796,10 +797,14 @@ def exclude_tests_below(path):
exclude_test('tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN')

# absinterp and thus the refcount-checker have bit-rotted:
if GCC_VERSION >= 7000:
if GCC_VERSION >= 5000:
exclude_tests_below('tests/cpychecker/absinterp')
exclude_tests_below('tests/cpychecker/refcounts')

# RuntimeError repr seems to have lost a trailing comma, perhaps in Python 3.7
if sys.version_info[0] == 3 and sys.version_info[1] >= 7:
exclude_tests_below('tests/plugin/namespace')

def run_one_test(testdir):
try:
sys.stdout.write('%s: ' % testdir)
Expand Down