| 1 |
name: "Check amalgamation" |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
|
| 6 |
permissions: |
| 7 |
contents: read |
| 8 |
|
| 9 |
jobs: |
| 10 |
save: |
| 11 |
runs-on: ubuntu-latest |
| 12 |
steps: |
| 13 |
- name: Harden Runner |
| 14 |
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf |
| 15 |
with: |
| 16 |
egress-policy: audit |
| 17 |
|
| 18 |
- name: Save PR number |
| 19 |
run: | |
| 20 |
mkdir -p ./pr |
| 21 |
echo ${{ github.event.number }} > ./pr/number |
| 22 |
echo ${{ github.event.pull_request.user.login }} > ./pr/author |
| 23 |
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 |
| 24 |
with: |
| 25 |
name: pr |
| 26 |
path: pr/ |
| 27 |
|
| 28 |
check: |
| 29 |
runs-on: ubuntu-latest |
| 30 |
env: |
| 31 |
MAIN_DIR: ${{ github.workspace }}/main |
| 32 |
INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann |
| 33 |
TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate |
| 34 |
|
| 35 |
steps: |
| 36 |
- name: Harden Runner |
| 37 |
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf |
| 38 |
with: |
| 39 |
egress-policy: audit |
| 40 |
|
| 41 |
- name: Checkout pull request |
| 42 |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 43 |
with: |
| 44 |
path: main |
| 45 |
ref: ${{ github.event.pull_request.head.sha }} |
| 46 |
|
| 47 |
- name: Checkout tools |
| 48 |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 49 |
with: |
| 50 |
path: tools |
| 51 |
ref: develop |
| 52 |
|
| 53 |
- name: Install astyle |
| 54 |
run: | |
| 55 |
python3 -mvenv venv |
| 56 |
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt |
| 57 |
|
| 58 |
- name: Check amalgamation |
| 59 |
run: | |
| 60 |
cd $MAIN_DIR |
| 61 |
|
| 62 |
rm -fr $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json_fwd.hpp~ |
| 63 |
cp $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json.hpp~ |
| 64 |
cp $INCLUDE_DIR/json_fwd.hpp $INCLUDE_DIR/json_fwd.hpp~ |
| 65 |
|
| 66 |
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s . |
| 67 |
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s . |
| 68 |
echo "Format (1)" |
| 69 |
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp |
| 70 |
|
| 71 |
diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp |
| 72 |
diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp |
| 73 |
|
| 74 |
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=orig $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) |
| 75 |
echo Check |
| 76 |
find $MAIN_DIR -name '*.orig' -exec false {} \+ |