diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d18b9b0..436952f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: if: runner.os == 'Linux' run: | sudo apt update - sudo apt install -y mingw-w64 rpm alien nuget musl-tools tmux + sudo apt install -y rpm alien musl-tools tmux sudo apt remove -y jq - name: Set up macOS (AMD64 and ARM64) @@ -173,23 +173,6 @@ jobs: ./scripts/ci-create-debian-package.sh ./scripts/ci-create-rpm-package.sh - - name: Build on Linux (${{ env.AMD64_WINDOWS_MINGW }}) - if: runner.os == 'Linux' - env: - PREFIX: ${{ env.AMD64_WINDOWS_MINGW }} - CC: x86_64-w64-mingw32-gcc - MAKE: make - RUN_TESTS: false - CXX: x86_64-w64-mingw32-g++ - CPP: x86_64-w64-mingw32-cpp - RANLIB: x86_64-w64-mingw32-ranlib - AR: x86_64-w64-mingw32-ar - NM: x86_64-w64-mingw32-nm - WINDRES: x86_64-w64-mingw32-windres - run: | - ./scripts/ci-build.sh - ./scripts/ci-create-nuget-package.sh - - name: Build on macOS (${{ env.AMD64_MACOSX_GCC }}) if: matrix.os == 'macos-13' env: @@ -322,28 +305,6 @@ jobs: retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} if-no-files-found: error - - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip) - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - env: - ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} - retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} - if-no-files-found: error - - - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg) - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - env: - ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} - retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} - if-no-files-found: error - - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_GCC }}.zip) if: matrix.os == 'macos-13' uses: actions/upload-artifact@v4 @@ -399,17 +360,6 @@ jobs: retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} if-no-files-found: error - - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz) - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - env: - ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} - retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} - if-no-files-found: error - - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_GCC }}.tar.gz) if: matrix.os == 'macos-13' uses: actions/upload-artifact@v4 @@ -432,14 +382,10 @@ jobs: retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} if-no-files-found: error - # --- Upload release artifacts --- - - name: Upload release artifacts if: startsWith(github.ref, 'refs/tags/v') run: ./scripts/ci-upload-release-artifacts.sh - # --- Update homebrew tap --- - - name: Update homebrew tap (liquidaty/homebrew-zsv) if: ${{ startsWith(github.ref, 'refs/tags/v') && matrix.os == 'macos-13' }} env: @@ -464,7 +410,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build on Linux (${{ env.AMD64_FREEBSD_GCC }}) + - name: Build (${{ env.AMD64_FREEBSD_GCC }}) uses: cross-platform-actions/action@v0.25.0 env: PREFIX: ${{ env.AMD64_FREEBSD_GCC }} @@ -513,7 +459,113 @@ jobs: retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} if-no-files-found: error - # --- Upload release artifacts --- + - name: Upload release artifacts + if: startsWith(github.ref, 'refs/tags/v') + run: ./scripts/ci-upload-release-artifacts.sh + + ci-mingw: + needs: [tag, clang-format, cppcheck, shellcheck] + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + attestations: write + + env: + TAG: ${{ needs.tag.outputs.TAG }} + + steps: + - name: Set up apt dependencies + run: | + sudo apt update + sudo apt install -y mingw-w64 nuget + sudo apt remove -y jq + + - name: Set VCPKG_MINGW_INSTALL_ROOT env var + run: echo "VCPKG_MINGW_INSTALL_ROOT=$VCPKG_INSTALLATION_ROOT/installed/x64-mingw-static" >>"$GITHUB_ENV" + + - name: Cache ncurses + uses: actions/cache@v4 + id: cache-ncurses + with: + key: ncurses:x64-mingw-static + path: ${{ env.VCPKG_MINGW_INSTALL_ROOT }} + + - name: Install ncurses with wide character support using vcpkg + if: ${{ steps.cache-ncurses.outputs.cache-hit != 'true' }} + run: | + NCURSES_PORTFILE="$VCPKG_INSTALLATION_ROOT/ports/ncurses/portfile.cmake" + cd "$VCPKG_INSTALLATION_ROOT" + if ! grep -- "--enable-widec" "$NCURSES_PORTFILE" >/dev/null; then + sed 's|--enable-pc-files|--enable-pc-files --enable-widec|' -i "$NCURSES_PORTFILE" + fi + ./vcpkg install ncurses:x64-mingw-static + tree -h ./installed/x64-mingw-static + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build (${{ env.AMD64_WINDOWS_MINGW }}) + env: + PREFIX: ${{ env.AMD64_WINDOWS_MINGW }} + CC: x86_64-w64-mingw32-gcc + MAKE: make + RUN_TESTS: false + CXX: x86_64-w64-mingw32-g++ + CPP: x86_64-w64-mingw32-cpp + RANLIB: x86_64-w64-mingw32-gcc-ranlib + AR: x86_64-w64-mingw32-gcc-ar + NM: x86_64-w64-mingw32-gcc-nm + WINDRES: x86_64-w64-mingw32-windres + CFLAGS: -I${{ env.VCPKG_MINGW_INSTALL_ROOT }}/include + LDFLAGS: -L${{ env.VCPKG_MINGW_INSTALL_ROOT }}/lib + run: | + ./scripts/ci-build.sh + ./scripts/ci-create-nuget-package.sh + + - name: Prepare build artifacts for upload + run: ./scripts/ci-prepare-artifacts-for-upload.sh + + - name: Attest build artifacts for release + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/attest-build-provenance@v1 + with: + subject-path: ${{ env.ARTIFACT_DIR }}/* + + - name: Verify attestations of release artifacts + if: startsWith(github.ref, 'refs/tags/v') + run: ./scripts/ci-verify-attestations.sh + + - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip) + uses: actions/upload-artifact@v4 + env: + ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + if-no-files-found: error + + - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz) + uses: actions/upload-artifact@v4 + env: + ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + if-no-files-found: error + + - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg) + uses: actions/upload-artifact@v4 + env: + ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }} + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + if-no-files-found: error - name: Upload release artifacts if: startsWith(github.ref, 'refs/tags/v') diff --git a/.gitignore b/.gitignore index 9b769b4e..5cc11901 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ nuget-feed homebrew-zsv cppcheck* tmp +include/zsv.h +app/test/worldcitiespop_mil.csv +data/quoted5.csv diff --git a/app/sheet.c b/app/sheet.c index 9a23e444..b6d41d2c 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -17,7 +17,11 @@ #include #if defined(WIN32) || defined(_WIN32) +#ifdef HAVE_NCURSESW +#include +#else #include +#endif // HAVE_NCURSESW #else #if __has_include() #include diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh index 937ffb86..4bcd6dd9 100755 --- a/scripts/ci-build.sh +++ b/scripts/ci-build.sh @@ -37,6 +37,7 @@ echo "[INF] Building and generating artifacts" echo "[INF] PWD: $PWD" echo "[INF] PREFIX: $PREFIX" echo "[INF] CC: $CC" +echo "[INF] CFLAGS: $CFLAGS" echo "[INF] LDFLAGS: $LDFLAGS" echo "[INF] MAKE: $MAKE" echo "[INF] RUN_TESTS: $RUN_TESTS" diff --git a/scripts/ci-run-shellcheck.sh b/scripts/ci-run-shellcheck.sh index a387d5f0..790a9c3e 100755 --- a/scripts/ci-run-shellcheck.sh +++ b/scripts/ci-run-shellcheck.sh @@ -14,39 +14,53 @@ echo "[INF] shellcheck version [$VERSION]" echo "[INF] Running shellcheck..." -shellcheck --format=tty \ +echo "[INF] Generating tty output..." +OUTPUT_TTY="$(shellcheck --format=tty \ configure \ app/test/*.sh \ scripts/*.sh \ - setup-action/scripts/*.bash || true + setup-action/scripts/*.bash 2>&1 || true)" + +echo "[INF] Generating diff output..." +OUTPUT_DIFF="$(shellcheck --format=diff \ + configure \ + app/test/*.sh \ + scripts/*.sh \ + setup-action/scripts/*.bash 2>&1 || true)" + +if [ "$OUTPUT_TTY" != "" ] && [ "$OUTPUT_DIFF" != "" ]; then + echo "[ERR] Issues found!" + echo "[ERR] Dumping tty output..." + echo "$OUTPUT_TTY" + echo "[ERR] Dumping diff output..." + echo "$OUTPUT_DIFF" +else + echo "[INF] No issues found!" +fi if [ "$CI" = true ]; then + echo "[INF] Generating Markdown step summary..." { - echo "
" - echo "Shellcheck Summary (tty format)" - echo - echo '```' - shellcheck --format=tty \ - configure \ - app/test/*.sh \ - scripts/*.sh \ - setup-action/scripts/*.bash \ - 2>&1 || true - echo '```' - echo "
" - echo - echo "
" - echo "Shellcheck Summary (diff format)" - echo - echo '```diff' - shellcheck --format=diff \ - configure \ - app/test/*.sh \ - scripts/*.sh \ - setup-action/scripts/*.bash \ - 2>&1 || true - echo '```' - echo "
" + if [ "$OUTPUT_TTY" != "" ] && [ "$OUTPUT_DIFF" != "" ]; then + echo "
" + echo "Shellcheck Summary (tty format)" + echo + echo '```' + echo "$OUTPUT_TTY" + echo '```' + echo + echo "
" + echo + echo "
" + echo "Shellcheck Summary (diff format)" + echo + echo '```diff' + echo "$OUTPUT_DIFF" + echo '```' + echo "
" + else + echo "No issues found!" + fi } >>"$GITHUB_STEP_SUMMARY" fi