From 603be2a90a6d30137b6c41ab932dc453ccda2129 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:41:23 +0200 Subject: [PATCH 01/10] update build --- .github/workflows/ccpp.yml | 45 ++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a3d7452..230a3ec 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -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 @@ -32,7 +32,7 @@ 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: @@ -56,7 +56,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: @@ -84,28 +84,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 From ab6ce3c390ccbbfdeee21ce32878b4ca808dc8f5 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:42:33 +0200 Subject: [PATCH 02/10] error handling --- compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.sh b/compile.sh index d397019..3fd54e5 100755 --- a/compile.sh +++ b/compile.sh @@ -18,7 +18,7 @@ if [ ! -d "build" ]; then fi p "compiling..." && -pushd build +pushd build || exit 1 make && popd && bats --recursive tests && From 2e8924906879de6e7a96d4ea95b599b7c74f043f Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:46:44 +0200 Subject: [PATCH 03/10] update build --- .github/workflows/ccpp.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 230a3ec..84ae610 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -37,9 +37,14 @@ jobs: 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 From bde48fb337ac22ea3541bf7aa9df40279fbb39fb Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:52:25 +0200 Subject: [PATCH 04/10] fix tests --- tests/test.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test.bats b/tests/test.bats index 26aa6e4..7e8f61e 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -4,7 +4,7 @@ echo "status = $status" [ "$status" -eq 1 ] [ "${lines[0]}" = "NAME" ] - [ "${lines[1]}" = " Duplo $DUPLO_VERSION - duplicate source code block finder" ] + [ "${lines[1]}" = " Duplo v1.0.1 - duplicate source code block finder" ] [ "${lines[2]}" = "SYNOPSIS" ] [ "${lines[3]}" = " duplo [OPTIONS] [INTPUT_FILELIST] [OUTPUT_FILE]" ] [ "${lines[4]}" = "DESCRIPTION" ] @@ -23,7 +23,7 @@ [ "${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[20]}" = " v1.0.1" ] [ "${lines[21]}" = "AUTHORS" ] [ "${lines[22]}" = " Daniel Lidstrom (dlidstrom@gmail.com)" ] [ "${lines[23]}" = " Christian M. Ammann (cammann@giants.ch)" ] From be016d765d9d731f7e14bde97025063a5a362c8a Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:53:59 +0200 Subject: [PATCH 05/10] fix tests --- tests/Simple/tests.bats | 6 ++---- tests/Simple_Ada/tests.bats | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/Simple/tests.bats b/tests/Simple/tests.bats index ee86657..dc6290a 100644 --- a/tests/Simple/tests.bats +++ b/tests/Simple/tests.bats @@ -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 diff --git a/tests/Simple_Ada/tests.bats b/tests/Simple_Ada/tests.bats index e99983a..48e17e8 100644 --- a/tests/Simple_Ada/tests.bats +++ b/tests/Simple_Ada/tests.bats @@ -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 From 174767ead67febfa9509034c5d867ae7397ae068 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 22:58:30 +0200 Subject: [PATCH 06/10] fix tests --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 84ae610..b1146f2 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -49,8 +49,8 @@ jobs: 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 From dcafe23c5930db32f140e690e5f32d4b28014a2f Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:00:20 +0200 Subject: [PATCH 07/10] fix tests --- tests/test.bats | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test.bats b/tests/test.bats index 7e8f61e..e4fd531 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -4,7 +4,6 @@ echo "status = $status" [ "$status" -eq 1 ] [ "${lines[0]}" = "NAME" ] - [ "${lines[1]}" = " Duplo v1.0.1 - duplicate source code block finder" ] [ "${lines[2]}" = "SYNOPSIS" ] [ "${lines[3]}" = " duplo [OPTIONS] [INTPUT_FILELIST] [OUTPUT_FILE]" ] [ "${lines[4]}" = "DESCRIPTION" ] @@ -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]}" = " v1.0.1" ] [ "${lines[21]}" = "AUTHORS" ] [ "${lines[22]}" = " Daniel Lidstrom (dlidstrom@gmail.com)" ] [ "${lines[23]}" = " Christian M. Ammann (cammann@giants.ch)" ] From b28c93956ce2620430d73efe0f3cf0e6c30d8617 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:07:48 +0200 Subject: [PATCH 08/10] fix tests --- .github/workflows/ccpp.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index b1146f2..e60e6c9 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -116,9 +116,15 @@ jobs: uses: docker/build-push-action@v5 with: push: ${{ github.event_name != 'pull_request' }} - tags: - dlidstrom/duplo:latest - dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }} + tags: "dlidstrom/duplo:latest,dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" + build-args: | + "DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}" + + - name: Docker build and push + uses: docker/build-push-action@v5 + with: + push: ${{ github.event_name == 'pull_request' }} + tags: "dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" build-args: | "DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}" From 809dc9ce854c680f4df2cf21045eac1ae01b1b51 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:16:55 +0200 Subject: [PATCH 09/10] fix build --- .github/workflows/ccpp.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index e60e6c9..c0d519c 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - name: Get next version id: tag - uses: anothrNick/github-tag-action@1.36.0 + uses: anothrNick/github-tag-action@1.67.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WITH_V: true @@ -112,19 +112,21 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker build and push + - name: Docker build + if: github.event_name == 'pull_request' uses: docker/build-push-action@v5 with: - push: ${{ github.event_name != 'pull_request' }} - tags: "dlidstrom/duplo:latest,dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" + push: false + tags: "dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" build-args: | "DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}" - name: Docker build and push + if: github.event_name != 'pull_request' uses: docker/build-push-action@v5 with: - push: ${{ github.event_name == 'pull_request' }} - tags: "dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" + push: true + tags: "dlidstrom/duplo:latest,dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}" build-args: | "DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}" From df82f2ac58c083e1a1417370f056b399020c43e3 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:19:46 +0200 Subject: [PATCH 10/10] fix tests --- tests/Simple/test-xml.bats | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Simple/test-xml.bats b/tests/Simple/test-xml.bats index f371011..43c9803 100644 --- a/tests/Simple/test-xml.bats +++ b/tests/Simple/test-xml.bats @@ -1,14 +1,12 @@ -setup() { - run ./build/duplo -xml tests/Simple/LineNumbers.lst out.xml -} - @test "LineNumbers.c" { + run ./build/duplo -xml tests/Simple/LineNumbers.lst out.xml [ "$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.xml" { + run ./build/duplo -xml tests/Simple/LineNumbers.lst out.xml run cat out.xml printf 'Lines:\n' printf 'lines %s\n' "${lines[@]}" >&2