Skip to content
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

GH Actions: Fix code formatter action #51

Merged
merged 2 commits into from
Nov 19, 2024
Merged
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
18 changes: 10 additions & 8 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ name: Clang format
on: [pull_request]

jobs:
clang-format-8:
runs-on: ubuntu-latest
clang-format:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run clang-foramt on changed files
- name: Run clang-format on changed files
run: |
set -x
sudo apt install clang-format
git config --global --add safe.directory '*'
git fetch origin ${{ github.event.pull_request.base.ref }}
git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}
BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }})
COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -i -v LinkDef)
RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES})
COMMIT_FILES=$(git diff --name-only "${BASE_COMMIT}" | grep -i -v LinkDef)
RESULT_OUTPUT=$(git clang-format --commit "${BASE_COMMIT}" --diff --binary "$(which clang-format)" -- "${COMMIT_FILES}")
if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then
exit 0
else
git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8)
git clang-format --commit "$BASE_COMMIT" --diff --binary "$(which clang-format)"
echo "$RESULT_OUTPUT"
exit 1
fi
fi
3 changes: 1 addition & 2 deletions src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void getValueSpecialization(void)
vString = f.getValue<std::string>(s);
}

//template void ConfigFile::getValue<float>(std::string, float&);
// template void ConfigFile::getValue<float>(std::string, float&);

// http://stackoverflow.com/questions/4586768/how-to-iterate-a-boost-property-tree
string indent(int level)
Expand Down Expand Up @@ -223,4 +223,3 @@ ConfigFileBrowser::Iterator ConfigFileBrowser::end()
{
return Iterator(this, ptPtr->end(), ptPtr->end());
}

1 change: 0 additions & 1 deletion src/Daemon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,3 @@ Daemon::LoopStatus Daemon::doLoop()

// todo
// boost exceptions?

1 change: 0 additions & 1 deletion src/Exception.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ const char* Exception::what() const noexcept

} // namespace Common
} // namespace AliceO2

1 change: 0 additions & 1 deletion src/Iommu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ bool isEnabled()
} // namespace Iommu
} // namespace Common
} // namespace AliceO2

3 changes: 1 addition & 2 deletions src/LineBuffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ int LineBuffer::getNextLine(std::string& nextLine)
return 0;
}

//void LineBuffer::appendString(const char *s) {}

// void LineBuffer::appendString(const char *s) {}
5 changes: 2 additions & 3 deletions src/MemPool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void* MemPool::getPage()
int newIx = (lastPageIndexGet + 1 + i) % numberOfPages;
if (!pageIsUsed[newIx].test_and_set()) {
lastPageIndexGet = newIx;
//printf("getPage() scan => %d\n",j);
// printf("getPage() scan => %d\n",j);
return pageTable[newIx];
}
j++;
Expand All @@ -109,7 +109,7 @@ void MemPool::releasePage(void* pagePtr)
if (pagePtr == pageTable[pageIx]) {
pageIsUsed[pageIx].clear();
lastPageIndexRelease = pageIx;
//printf("realeasePage() scan => %d\n",j);
// printf("realeasePage() scan => %d\n",j);
return;
}
j++;
Expand All @@ -120,4 +120,3 @@ int MemPool::getPageSize()
{
return pageSize;
}

1 change: 0 additions & 1 deletion src/Program.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,3 @@ int Program::execute(int argc, char** argv)

} // namespace Common
} // namespace AliceO2

3 changes: 1 addition & 2 deletions src/SimpleLog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int SimpleLog::Impl::logV(SimpleLog::Impl::Severity s, const char* message, va_l
} else if (s == Severity::Warning) {
ix += snprintf(&buffer[ix], len - ix, "Warning - ");
} else {
//ix+=snprintf(&buffer[ix], len-ix, "");
// ix+=snprintf(&buffer[ix], len-ix, "");
}
}

Expand Down Expand Up @@ -410,4 +410,3 @@ void SimpleLog::Impl::rotate()
}

/// \todo: thread to flush output every 1 second

1 change: 0 additions & 1 deletion src/SuffixNumber.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ const std::vector<std::pair<std::string, const size_t>>& get()
} // namespace _SuffixNumberTable
} // namespace Common
} // namespace AliceO2

1 change: 0 additions & 1 deletion src/System.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ void assertFileSystemType(const std::string& path, const std::set<std::string>&
} // namespace System
} // namespace Common
} // namespace AliceO2

1 change: 0 additions & 1 deletion src/Thread.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,3 @@ std::string Thread::getName()
{
return name;
}

1 change: 0 additions & 1 deletion test/TestBasicThread.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ BOOST_AUTO_TEST_CASE(TestBasicThread)
thread.join();
BOOST_CHECK(number > 0);
}

1 change: 0 additions & 1 deletion test/TestIommu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ BOOST_AUTO_TEST_CASE(TestIsEnabled)
{
BOOST_CHECK_NO_THROW(AliceO2::Common::Iommu::isEnabled());
}

1 change: 0 additions & 1 deletion test/TestSuffixNumber.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ BOOST_AUTO_TEST_CASE(TestFloatingPoint)
sn.setNumber("-123");
BOOST_CHECK_EQUAL(sn.getNumber(), -123);
}

1 change: 0 additions & 1 deletion test/TestSuffixOption.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ BOOST_AUTO_TEST_CASE(TestSuffixOption)
BOOST_CHECK(numberB.getNumber() == 123);
BOOST_CHECK(numberC == -1000.0);
}

1 change: 0 additions & 1 deletion test/TestSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ BOOST_AUTO_TEST_CASE(TestIsFileSystemTypeAnyOf)
BOOST_CHECK(System::isFileSystemTypeAnyOf("/sys", { "blahfs", "ext42" }).first == false);
#endif
}

1 change: 0 additions & 1 deletion test/testDaemon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ int main(int argc, char* argv[])
Daemon d(argc, argv);
return d.run();
}

1 change: 0 additions & 1 deletion test/testFifo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ BOOST_AUTO_TEST_CASE(fifo_test)

printf("fifoSz=%d sum=%d\n", fifoSz, sum2);
}

7 changes: 3 additions & 4 deletions test/testSimpleLog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ int main()

SimpleLog theLog;
theLog.setLogFile("/tmp/test.log", 100, 4, 0);
for (int i=0; i<10; i++) {
theLog.info("test message %d",i);
for (int i = 0; i < 10; i++) {
theLog.info("test message %d", i);
}
//sleep(10);
// sleep(10);
return 0;
}

1 change: 0 additions & 1 deletion test/testTimer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ BOOST_AUTO_TEST_CASE(timer_test)

BOOST_CHECK_EQUAL(success, 1);
}