Skip to content

Commit

Permalink
Build with GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed May 15, 2020
1 parent 057aa74 commit 2a28007
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 13 deletions.
87 changes: 77 additions & 10 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,85 @@ name: C/C++ CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches:
- master

jobs:
build:

build-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: init
run: mkdir -p build && popd build && cmake .. && popd
- name: compile
run: ./compile
- name: build
run: |
sudo npm install -g bats
mkdir -p build && pushd build && cmake .. && popd
./compile.sh
zip --junk-paths duplo-linux build/duplo
- name: upload linux artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: duplo-linux.zip
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: build
run: |
brew unlink bats && brew install bats-core
mkdir -p build && pushd build && cmake .. && popd
./compile.sh
zip --junk-paths duplo-macos build/duplo
- name: upload macos artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: duplo-macos.zip
upload-release:
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- uses: actions/checkout@master
with:
fetch-depth: '0'
- name: Bump version and push tag
id: tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
- name: create release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.new_tag }}
release_name: Release ${{ steps.tag.outputs.new_tag }}
draft: false
prerelease: false
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- name: upload macos
id: upload-macos
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-macos.zip
asset_name: duplo-macos.zip
asset_content_type: application/zip
- name: upload linux
id: upload-linux
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-linux.zip
asset_name: duplo-linux.zip
asset_content_type: application/zip
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ build
.vscode
out.txt
files.lst
CMakeFiles
CMakeCache.txt
Makefile
cmake_install.cmake
10 changes: 10 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM gitpod/workspace-full

USER gitpod

# Install custom tools, runtime, etc. using apt-get
# For example, the command below would install "bastet" - a command line tetris clone:
#
# RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/*
#
# More information: https://www.gitpod.io/docs/config-docker/
4 changes: 4 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tasks:
- init: cmake .
image:
file: .gitpod.Dockerfile
4 changes: 4 additions & 0 deletions .theia/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.autoSave": "on",
"editor.renderWhitespace": "all"
}
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Duplo (C/C++/Java Duplicate Source Code Block Finder) <!-- omit in toc -->

![C/C++ CI](https://github.com/dlidstrom/Duplo/workflows/C/C++%20CI/badge.svg)

- [General Information](#general-information)
- [Maintainer](#maintainer)
- [File Format Support](#file-format-support)
Expand Down
3 changes: 2 additions & 1 deletion src/Duplo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ namespace {
if (longestFiles.size() < 10) {
addSorted(numLines, lines[i]);
} else {
auto [l, _] = longestFiles.back();
auto [l, r] = longestFiles.back();
(void)r;
if (l < numLines) {
addSorted(numLines, lines[i]);
}
Expand Down
7 changes: 6 additions & 1 deletion src/FileTypeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "StringUtil.h"

#include <algorithm>
#include <cctype>

FileTypeBase::FileTypeBase(bool ignorePrepStuff, unsigned minChars)
: m_ignorePrepStuff(ignorePrepStuff),
Expand All @@ -23,7 +24,11 @@ bool FileTypeBase::IsSourceLine(const std::string& line) const {

// must be at least one alpha-numeric character
bool isSourceLine =
tmp.size() >= m_minChars && std::find_if(std::begin(tmp), std::end(tmp), std::isalpha) != std::end(tmp);
tmp.size() >= m_minChars
&& std::find_if(
std::begin(tmp),
std::end(tmp),
[](int c) { return std::isalpha(c); }) != std::end(tmp);
return isSourceLine;
}

Expand Down
2 changes: 2 additions & 0 deletions src/FileType_CS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "CstyleUtils.h"
#include "SourceLine.h"

#include <cstring>

FileType_CS::FileType_CS(bool ignorePrepStuff, unsigned minChars)
: FileTypeBase(ignorePrepStuff, minChars) {
}
Expand Down
2 changes: 2 additions & 0 deletions src/FileType_S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "NoopLineFilter.h"
#include "SourceLine.h"

#include <cstring>

FileType_S::FileType_S(bool ignorePrepStuff, unsigned minChars)
: FileTypeBase(ignorePrepStuff, minChars) {
}
Expand Down
2 changes: 2 additions & 0 deletions src/FileType_VB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "NoopLineFilter.h"
#include "SourceLine.h"

#include <cstring>

FileType_VB::FileType_VB(bool ignorePrepStuff, unsigned minChars)
: FileTypeBase(ignorePrepStuff, minChars) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/StringUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int StringUtil::Split(const std::string& input, const std::string& delimiter, st
// At the end is always a marker
positions.push_back(input.size());

for (auto i = 0; i < positions.size() - 1; i++) {
for (auto i = 0U; i < positions.size() - 1; i++) {
std::string s;

auto start = positions[i] + sizeDelim;
Expand Down

0 comments on commit 2a28007

Please sign in to comment.