Skip to content

Commit 2a28007

Browse files
committed
Build with GitHub actions
1 parent 057aa74 commit 2a28007

File tree

12 files changed

+116
-13
lines changed

12 files changed

+116
-13
lines changed

.github/workflows/ccpp.yml

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,85 @@ name: C/C++ CI
22

33
on:
44
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
5+
branches:
6+
- master
87

98
jobs:
10-
build:
11-
9+
build-linux:
1210
runs-on: ubuntu-latest
13-
1411
steps:
1512
- uses: actions/checkout@v2
16-
- name: init
17-
run: mkdir -p build && popd build && cmake .. && popd
18-
- name: compile
19-
run: ./compile
13+
- name: build
14+
run: |
15+
sudo npm install -g bats
16+
mkdir -p build && pushd build && cmake .. && popd
17+
./compile.sh
18+
zip --junk-paths duplo-linux build/duplo
19+
- name: upload linux artifact
20+
uses: actions/upload-artifact@v1
21+
with:
22+
name: uploads
23+
path: duplo-linux.zip
24+
build-macos:
25+
runs-on: macos-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: build
29+
run: |
30+
brew unlink bats && brew install bats-core
31+
mkdir -p build && pushd build && cmake .. && popd
32+
./compile.sh
33+
zip --junk-paths duplo-macos build/duplo
34+
- name: upload macos artifact
35+
uses: actions/upload-artifact@v1
36+
with:
37+
name: uploads
38+
path: duplo-macos.zip
39+
upload-release:
40+
runs-on: ubuntu-latest
41+
needs: [build-linux, build-macos]
42+
steps:
43+
- uses: actions/checkout@master
44+
with:
45+
fetch-depth: '0'
46+
- name: Bump version and push tag
47+
id: tag
48+
uses: anothrNick/[email protected]
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
WITH_V: true
52+
DEFAULT_BUMP: patch
53+
- name: create release
54+
id: create_release
55+
uses: actions/create-release@master
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
with:
59+
tag_name: ${{ steps.tag.outputs.new_tag }}
60+
release_name: Release ${{ steps.tag.outputs.new_tag }}
61+
draft: false
62+
prerelease: false
63+
- name: download artifacts
64+
uses: actions/download-artifact@v1
65+
with:
66+
name: uploads
67+
- name: upload macos
68+
id: upload-macos
69+
uses: actions/[email protected]
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
upload_url: ${{ steps.create_release.outputs.upload_url }}
74+
asset_path: ./uploads/duplo-macos.zip
75+
asset_name: duplo-macos.zip
76+
asset_content_type: application/zip
77+
- name: upload linux
78+
id: upload-linux
79+
uses: actions/[email protected]
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
with:
83+
upload_url: ${{ steps.create_release.outputs.upload_url }}
84+
asset_path: ./uploads/duplo-linux.zip
85+
asset_name: duplo-linux.zip
86+
asset_content_type: application/zip

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ build
1414
.vscode
1515
out.txt
1616
files.lst
17+
CMakeFiles
18+
CMakeCache.txt
19+
Makefile
20+
cmake_install.cmake

.gitpod.Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM gitpod/workspace-full
2+
3+
USER gitpod
4+
5+
# Install custom tools, runtime, etc. using apt-get
6+
# For example, the command below would install "bastet" - a command line tetris clone:
7+
#
8+
# RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/*
9+
#
10+
# More information: https://www.gitpod.io/docs/config-docker/

.gitpod.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tasks:
2+
- init: cmake .
3+
image:
4+
file: .gitpod.Dockerfile

.theia/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.autoSave": "on",
3+
"editor.renderWhitespace": "all"
4+
}

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Duplo (C/C++/Java Duplicate Source Code Block Finder) <!-- omit in toc -->
22

3+
![C/C++ CI](https://github.com/dlidstrom/Duplo/workflows/C/C++%20CI/badge.svg)
4+
35
- [General Information](#general-information)
46
- [Maintainer](#maintainer)
57
- [File Format Support](#file-format-support)

src/Duplo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ namespace {
116116
if (longestFiles.size() < 10) {
117117
addSorted(numLines, lines[i]);
118118
} else {
119-
auto [l, _] = longestFiles.back();
119+
auto [l, r] = longestFiles.back();
120+
(void)r;
120121
if (l < numLines) {
121122
addSorted(numLines, lines[i]);
122123
}

src/FileTypeBase.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "StringUtil.h"
55

66
#include <algorithm>
7+
#include <cctype>
78

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

2425
// must be at least one alpha-numeric character
2526
bool isSourceLine =
26-
tmp.size() >= m_minChars && std::find_if(std::begin(tmp), std::end(tmp), std::isalpha) != std::end(tmp);
27+
tmp.size() >= m_minChars
28+
&& std::find_if(
29+
std::begin(tmp),
30+
std::end(tmp),
31+
[](int c) { return std::isalpha(c); }) != std::end(tmp);
2732
return isSourceLine;
2833
}
2934

src/FileType_CS.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "CstyleUtils.h"
44
#include "SourceLine.h"
55

6+
#include <cstring>
7+
68
FileType_CS::FileType_CS(bool ignorePrepStuff, unsigned minChars)
79
: FileTypeBase(ignorePrepStuff, minChars) {
810
}

src/FileType_S.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "NoopLineFilter.h"
44
#include "SourceLine.h"
55

6+
#include <cstring>
7+
68
FileType_S::FileType_S(bool ignorePrepStuff, unsigned minChars)
79
: FileTypeBase(ignorePrepStuff, minChars) {
810
}

0 commit comments

Comments
 (0)