Skip to content

Commit

Permalink
Merge dcafe23 into 0bf5dee
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed Apr 3, 2024
2 parents 0bf5dee + dcafe23 commit cbb7893
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
54 changes: 38 additions & 16 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
bump-tag-dry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Get next version
id: tag
uses: anothrNick/github-tag-action@1.36.0
Expand All @@ -32,20 +32,25 @@ jobs:
runs-on: ubuntu-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads

- uses: actions/setup-node@v4
with:
node-version: 18

- name: build
run: |
sudo npm install -g bats
npm install -g bats
export DUPLO_VERSION=`cat ./uploads/tag.txt`
mkdir -p build
pushd build
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
make
popd
./compile.sh
zip --junk-paths duplo-linux build/duplo
- name: upload linux artifact
uses: actions/upload-artifact@v1
Expand All @@ -56,7 +61,7 @@ jobs:
runs-on: macos-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -84,28 +89,45 @@ jobs:
uses: actions/download-artifact@v1
with:
name: uploads

- name: set version
run: echo "{DUPLO_VERSION}={$(cat ./uploads/tag.txt)}" >> $GITHUB_ENV
- name: print version
run: echo $DUPLO_VERSION
- uses: actions/checkout@master
id: version
run: |
DUPLO_VERSION=$(cat ./uploads/tag.txt)
echo $DUPLO_VERSION
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_ENV
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: docker/build-push-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: dlidstrom/duplo
tag_with_ref: true
# push: ${{ startsWith(github.ref, 'refs/tags/') }}
build_args: DUPLO_VERSION=${{ env.DUPLO_VERSION }}
tags: ${{ env.DUPLO_VERSION }}

- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
tags:
dlidstrom/duplo:latest
dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}
build-args: |
"DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}"
upload-release:
if: success()
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
Expand Down
2 changes: 1 addition & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ ! -d "build" ]; then
fi

p "compiling..." &&
pushd build
pushd build || exit 1
make &&
popd &&
bats --recursive tests &&
Expand Down
6 changes: 2 additions & 4 deletions tests/Simple/tests.bats
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
setup() {
run ./build/duplo tests/Simple/LineNumbers.lst out.txt
}

@test "LineNumbers.c" {
run ./build/duplo tests/Simple/LineNumbers.lst out.txt
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
[ "${lines[1]}" = "tests/Simple/LineNumbers.c found: 1 block(s)" ]
}

@test "LineNumbers.c out.txt" {
run ./build/duplo tests/Simple/LineNumbers.lst out.txt
run cat out.txt
printf 'Lines:\n'
printf 'lines %s\n' "${lines[@]}" >&2
Expand Down
6 changes: 2 additions & 4 deletions tests/Simple_Ada/tests.bats
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
setup() {
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst out.txt
}

@test "simple_log.adb" {
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst out.txt
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
[ "${lines[1]}" = "tests/Simple_Ada/simple_log.adb found: 6 block(s)" ]
}

@test "simple_log.adb out.txt" {
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst out.txt
run cat out.txt
printf 'Lines:\n'
printf 'lines %s\n' "${lines[@]}" >&2
Expand Down
2 changes: 0 additions & 2 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
echo "status = $status"
[ "$status" -eq 1 ]
[ "${lines[0]}" = "NAME" ]
[ "${lines[1]}" = " Duplo $DUPLO_VERSION - duplicate source code block finder" ]
[ "${lines[2]}" = "SYNOPSIS" ]
[ "${lines[3]}" = " duplo [OPTIONS] [INTPUT_FILELIST] [OUTPUT_FILE]" ]
[ "${lines[4]}" = "DESCRIPTION" ]
Expand All @@ -23,7 +22,6 @@
[ "${lines[17]}" = " INPUT_FILELIST input filelist (specify '-' to read from stdin)" ]
[ "${lines[18]}" = " OUTPUT_FILE output file" ]
[ "${lines[19]}" = "VERSION" ]
[ "${lines[20]}" = " $DUPLO_VERSION" ]
[ "${lines[21]}" = "AUTHORS" ]
[ "${lines[22]}" = " Daniel Lidstrom (dlidstrom@gmail.com)" ]
[ "${lines[23]}" = " Christian M. Ammann (cammann@giants.ch)" ]
Expand Down

0 comments on commit cbb7893

Please sign in to comment.