Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 0 additions & 39 deletions .github/bot-pr-format-base.sh

This file was deleted.

22 changes: 20 additions & 2 deletions .github/check-format.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
#!/usr/bin/env bash

cp .github/bot-pr-format-base.sh /tmp
source /tmp/bot-pr-format-base.sh
cp .github/bot-pr-base.sh /tmp
source /tmp/bot-pr-base.sh

echo -n "Run Pre-Commit checks"

git remote add fork "$HEAD_URL"
git fetch fork "$HEAD_BRANCH"
git fetch origin "$BASE_BRANCH"

# checkout current PR head
LOCAL_BRANCH=format-tmp-$HEAD_BRANCH
git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH

pipx run pre-commit run --show-diff-on-failure --color=always --from-ref "origin/$BASE_BRANCH" --to-ref HEAD || true

echo -n "Collecting information on changed files"

# check for changed files, replace newlines by \n
LIST_FILES=$(git diff --name-only | sed '$!s/$/\\n/' | tr -d '\n')
echo -n .

git diff > /tmp/format.patch
mv /tmp/format.patch .
echo -n .

bot_delete_comments_matching "Error: The following files need to be formatted"
echo -n .

if [[ "$LIST_FILES" != "" ]]; then
MESSAGE="The following files need to be formatted:\n"'```'"\n$LIST_FILES\n"'```'
MESSAGE="$MESSAGE\nYou can find a formatting patch under **Artifacts** [here]"
MESSAGE="$MESSAGE($JOB_URL) or run "'`format!` if you have write access to Ginkgo'
bot_error "$MESSAGE"
fi
echo .
6 changes: 3 additions & 3 deletions .github/format-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ LOCAL_BRANCH=rebase-tmp-$HEAD_BRANCH
git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH

# save scripts from develop
pushd dev_tools/scripts
pushd dev_tools/scripts || exit 1
cp add_license.sh format_header.sh update_ginkgo_header.sh /tmp
popd
popd || exit 1

bot_delete_comments_matching "Error: Rebase failed"

Expand All @@ -30,7 +30,7 @@ git rebase --rebase-merges --empty=drop --no-keep-empty \
--exec "cp /tmp/add_license.sh /tmp/format_header.sh /tmp/update_ginkgo_header.sh dev_tools/scripts/ && \
dev_tools/scripts/add_license.sh && dev_tools/scripts/update_ginkgo_header.sh && \
for f in \$($DIFF_COMMAND | grep -E '$FORMAT_HEADER_REGEX'); do dev_tools/scripts/format_header.sh \$f; done && \
for f in \$($DIFF_COMMAND | grep -E '$FORMAT_REGEX'); do $CLANG_FORMAT -i \$f; done && \
pipx run pre-commit run --files $TO_FORMAT && \
git checkout dev_tools/scripts && (git diff >> /tmp/difflog; true) && (git diff --quiet || git commit -a --amend --no-edit --allow-empty)" \
base/$BASE_BRANCH 2>&1 || bot_error "Rebase failed, see the related [Action]($JOB_URL) for details"

Expand Down
45 changes: 41 additions & 4 deletions .github/format.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
#!/usr/bin/env bash

cp .github/bot-pr-format-base.sh /tmp
source /tmp/bot-pr-format-base.sh
source .github/bot-pr-base.sh

echo "Retrieving PR file list"
PR_FILES=$(bot_get_all_changed_files ${PR_URL})
NUM=$(echo "${PR_FILES}" | wc -l)
echo "PR has ${NUM} changed files"

TO_FORMAT="$(echo "$PR_FILES" | grep -E $EXTENSION_REGEX || true)"

git remote add fork "$HEAD_URL"
git fetch fork "$HEAD_BRANCH"

git config user.email "ginkgo.library@gmail.com"
git config user.name "ginkgo-bot"

# save scripts from develop
pushd dev_tools/scripts || exit 1
cp add_license.sh format_header.sh update_ginkgo_header.sh /tmp
popd || exit 1

# checkout current PR head
LOCAL_BRANCH=format-tmp-$HEAD_BRANCH
git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH

# restore files from develop
cp /tmp/add_license.sh dev_tools/scripts/
cp /tmp/format_header.sh dev_tools/scripts/
cp /tmp/update_ginkgo_header.sh dev_tools/scripts/

# format files
dev_tools/scripts/add_license.sh
dev_tools/scripts/update_ginkgo_header.sh
for f in $(echo "$TO_FORMAT" | grep -E $FORMAT_HEADER_REGEX); do dev_tools/scripts/format_header.sh "$f"; done
pipx run pre-commit run --files $TO_FORMAT || true

# restore formatting scripts so they don't appear in the diff
git checkout -- dev_tools/scripts/*.sh

# check for changed files, replace newlines by \n
LIST_FILES=$(git diff --name-only | sed '$!s/$/\\n/' | tr -d '\n')
CHANGES=$(git diff --name-only | sed '$!s/$/\\n/' | tr -d '\n')

echo "$CHANGES"

# commit changes if necessary
if [[ "$LIST_FILES" != "" ]]; then
if [[ "$CHANGES" != "" ]]; then
git commit -a -m "Format files

Co-authored-by: $USER_COMBINED"
Expand Down
29 changes: 10 additions & 19 deletions .github/workflows/bot-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: OnCommentPR

on:
issue_comment:
types: [created]
name: OnCommentPR

jobs:
label:
runs-on: ubuntu-latest
Expand All @@ -15,28 +17,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: cp --preserve .github/label.sh /tmp && /tmp/label.sh

check_format:
name: check-format
runs-on: ubuntu-22.04
if: github.event.issue.pull_request != '' && github.event.comment.body == 'check-format!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
steps:
- name: Checkout the latest code (shallow clone)
uses: actions/checkout@v3
with:
ref: develop
- name: Check for formatting changes
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: cp --preserve .github/check-format.sh /tmp && /tmp/check-format.sh
- name: Upload code formatting patch
if: failure()
uses: actions/upload-artifact@v3
with:
name: patch
path: format.patch
uses: ./.github/workflows/check-formatting.yml

format:
name: format
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
if: github.event.issue.pull_request != '' && github.event.comment.body == 'format!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
steps:
- name: Checkout the latest code (shallow clone)
Expand All @@ -46,8 +35,9 @@ jobs:
persist-credentials: false
- name: Commit formatting changes
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cp --preserve .github/format.sh /tmp && /tmp/format.sh

rebase:
name: rebase
if: github.event.issue.pull_request != '' && github.event.comment.body == 'rebase!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
Expand All @@ -63,6 +53,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: cp --preserve .github/rebase.sh /tmp && /tmp/rebase.sh

format-rebase:
name: format-rebase
if: github.event.issue.pull_request != '' && github.event.comment.body == 'format-rebase!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
Expand Down
59 changes: 6 additions & 53 deletions .github/workflows/bot-pr-updated.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,18 @@
name: OnSyncPR

on:
pull_request_target:
types: [opened,synchronize]
name: OnSyncPR

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
check-format:
runs-on: ubuntu-22.04
if: github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'OWNER'
steps:
- name: Checkout the latest code (shallow clone)
uses: actions/checkout@v3
with:
ref: develop
- name: Check for formatting changes
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: cp .github/check-format.sh /tmp && /tmp/check-format.sh
- name: Upload code formatting patch
if: failure()
uses: actions/upload-artifact@v3
with:
name: patch
path: format.patch
abidiff:
runs-on: ubuntu-latest
if: github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'OWNER'
env:
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=DEBUG -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -DGINKGO_BUILD_HWLOC=OFF -DGINKGO_BUILD_REFERENCE=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_SYCL=OFF
steps:
- name: Checkout the new code (shallow clone)
uses: actions/checkout@v3
with:
path: new
ref: ${{ github.event.pull_request.head.ref }}
- name: Checkout the old code (shallow clone)
uses: actions/checkout@v3
with:
path: old
ref: ${{ github.event.pull_request.base.ref }}
- name: Install abidiff
run: sudo apt-get install abigail-tools
- name: Build both libraries
run: |
mkdir build-new
mkdir build-old
cmake -B build-new new ${{ env.CMAKE_FLAGS }}
cmake -B build-old old ${{ env.CMAKE_FLAGS }}
cmake --build build-new -j`nproc`
cmake --build build-old -j`nproc`
- name: Compute abidiff
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: old/.github/abidiff.sh
- name: Upload ABI diff
if: failure()
uses: actions/upload-artifact@v3
with:
name: abi
path: abi.diff
uses: ./.github/workflows/check-formatting.yml

check-wiki-changelog:
runs-on: ubuntu-latest
if: github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'OWNER'
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check formatting
on:
workflow_call:

jobs:
pre-commit:
name: Run pre-commit hooks
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code (shallow clone)
uses: actions/checkout@v4
- name: Run Pre-Commit checks
run: cp .github/check-format.sh /tmp && /tmp/check-format.sh
id: pre-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload code formatting patch
if: ${{ failure() && steps.pre-commit.outcome == 'failure' }}
uses: actions/upload-artifact@v3
with:
name: patch
path: format.patch
5 changes: 2 additions & 3 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
fail-fast: false
matrix:
config:
- {compiler: "dpcpp", build_type: "Release", name: "intel/dpcpp/release/shared", mixed: "ON"}
- {compiler: "icpx", build_type: "Release", name: "intel/icpx/release/shared", mixed: "OFF"}
- {build_type: "Release", name: "intel/release/shared", "mixed": "ON"}
name: ${{ matrix.config.name }}
runs-on: [gpu_intel]

Expand All @@ -36,7 +35,7 @@ jobs:
spack find --loaded
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=install_ginkgo -DGINKGO_COMPILER_FLAGS="-ffp-model=precise" -DCMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_DPCPP_SINGLE_MODE=ON
cmake .. -DCMAKE_INSTALL_PREFIX=install_ginkgo -DGINKGO_COMPILER_FLAGS="-ffp-model=precise" -DCMAKE_CXX_COMPILER=dpcpp -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_DPCPP_SINGLE_MODE=ON
make -j8
ONEAPI_DEVICE_SELECTOR=level_zero:gpu ctest -j10 --output-on-failure

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/windows-msvc-ref.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ jobs:
fail-fast: false
matrix:
config:
# Debug shared exceeds symbol limit
# - {shared: "ON", build_type: "Debug", name: "reference/debug/shared"}
- {shared: "ON", build_type: "Debug", name: "reference/debug/shared"}
- {shared: "OFF", build_type: "Release", name: "reference/release/static"}
- {shared: "ON", build_type: "Release", name: "reference/release/shared"}
# Debug static needs too much storage
# - {shared: "OFF", build_type: "Debug", name: "reference/debug/static"}
name: msvc/${{ matrix.config.name }}
Expand Down
Loading