-
Notifications
You must be signed in to change notification settings - Fork 11
156 lines (127 loc) · 4.39 KB
/
readme_listings.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: readme_listings
defaults:
run:
shell: bash
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 13 * * 4'
jobs:
julia:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: jwlawson/[email protected]
with:
cmake-version: '3.26.x'
- run: pip install -e .
- run: pip install pytest-codeblocks pytest
- run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.jl', 'w'); f.writelines(block.code for block in code if block.syntax=='Julia'); f.close()"
- run: cat -n readme.jl
- uses: julia-actions/setup-julia@v1
- run: mkdir readme_output
- run: julia readme.jl > readme_output/julia.txt
- uses: actions/upload-artifact@v4
with:
name: readme_output-julia
path: readme_output
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: jwlawson/[email protected]
with:
cmake-version: '3.26.x'
- run: pip install -e .
- run: pip install pytest-codeblocks pytest
- run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.py', 'w'); f.writelines(block.code for block in code if block.syntax=='Python'); f.close()"
- run: cat -n readme.py
- run: mkdir readme_output
- run: python -We readme.py > readme_output/python.txt
- uses: actions/upload-artifact@v4
with:
name: readme_output-python
path: readme_output
fortran:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: |
sudo apt-get update
sudo apt-get install libnetcdff-dev
- run: |
cd readme_fortran
mkdir build
cd build
PARTMC_HOME=../../gitmodules/partmc cmake ..
make
- run: |
mkdir readme_output
cd readme_fortran
./build/main > ../readme_output/fortran.txt
- uses: actions/upload-artifact@v4
with:
name: readme_output-fortran
path: readme_output
assert:
runs-on: ubuntu-latest
needs: [julia, python, matlab, fortran]
steps:
- uses: actions/setup-python@v2
- run: pip install numpy
- uses: actions/download-artifact@v4
with:
pattern: readme_output-*
merge-multiple: true
path: readme_output
- run : python -c 'import numpy as np; import os; dir="readme_output/"; data=[float(np.loadtxt(dir+file)) for file in os.listdir(dir)]; print("data:", data); similar_as_first = np.array([abs(data[0]-k)/data[0] for k in data[1:]]); print("similar_as_first", similar_as_first); assert((similar_as_first < .5).all())'
matlab:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: jwlawson/[email protected]
with:
cmake-version: '3.26.x'
- run: |
echo "CC=gcc-9" >> $GITHUB_ENV
echo "CXX=g++-9" >> $GITHUB_ENV
VERBOSE=1 pip install --verbose -e .
- run: pip install pytest-codeblocks pytest
- run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.m', 'w'); f.writelines(block.code for block in code if block.syntax=='Matlab'); f.close()"
- run: cat -n readme.m
# see https://github.com/pybind/cmake_example/pull/164
- run: |
echo "pybind11_type=type" > pybind11_builtins.py
echo "PYTHONPATH=." >> $GITHUB_ENV
- uses: matlab-actions/setup-matlab@v0
with:
release: R2022a
- run: mkdir readme_output
- uses: matlab-actions/run-command@v0
with:
startup-options: -nojvm
command: diary('readme_output/matlab.txt'), readme
- uses: actions/upload-artifact@v4
with:
name: readme_output-matlab
path: readme_output