From 352b3d83403f77b84d76f0f377ab5ef5b7e27ea3 Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:24:21 +0200 Subject: [PATCH 1/2] fix build --- .github/workflows/ccpp.yml | 64 +++++++++++++++++++++++++++---------- compile.sh | 2 +- tests/Simple/test-xml.bats | 6 ++-- tests/Simple/tests.bats | 6 ++-- tests/Simple_Ada/tests.bats | 6 ++-- tests/test.bats | 2 -- 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a3d7452..c0d519c 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -11,10 +11,10 @@ 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 + uses: anothrNick/github-tag-action@1.67.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WITH_V: true @@ -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 @@ -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: @@ -84,28 +89,53 @@ 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 + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + 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: true + 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 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 && 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 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 diff --git a/tests/test.bats b/tests/test.bats index 26aa6e4..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 $DUPLO_VERSION - 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]}" = " $DUPLO_VERSION" ] [ "${lines[21]}" = "AUTHORS" ] [ "${lines[22]}" = " Daniel Lidstrom (dlidstrom@gmail.com)" ] [ "${lines[23]}" = " Christian M. Ammann (cammann@giants.ch)" ] From 1947add8d08d7aa5f634564117b5d00bfc838bae Mon Sep 17 00:00:00 2001 From: Daniel Lidstrom Date: Wed, 3 Apr 2024 23:27:40 +0200 Subject: [PATCH 2/2] fix tests --- tests/Quake2/tests.bats | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Quake2/tests.bats b/tests/Quake2/tests.bats index 57a290c..2434177 100644 --- a/tests/Quake2/tests.bats +++ b/tests/Quake2/tests.bats @@ -1,5 +1,6 @@ @test "g_chase.c" { - run ./build/duplo tests/Quake2/files.lst out.txt && cat out.txt + run ./build/duplo tests/Quake2/files.lst out.txt + cat out.txt printf 'lines %s\n' "${lines[@]}" >&2 echo "status = $status" [ "$status" -eq 0 ]