Skip to content

Commit

Permalink
Merge to main
Browse files Browse the repository at this point in the history
  • Loading branch information
CobbCoding1 committed Dec 18, 2024
2 parents 060a59f + d1678e4 commit 405d939
Show file tree
Hide file tree
Showing 63 changed files with 3,892 additions and 421 deletions.
185 changes: 97 additions & 88 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,9 @@ jobs:
- name: Run shellcheck
run: ./scripts/ci-run-shellcheck.sh

ci:
ci-linux:
needs: [tag, clang-format, cppcheck, shellcheck]

strategy:
matrix:
os: [ubuntu-22.04, macos-13, macos-14]

runs-on: ${{ matrix.os }}
runs-on: ubuntu-22.04
timeout-minutes: 15

env:
Expand All @@ -133,23 +128,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Linux
if: runner.os == 'Linux'
- name: Set up apt dependencies
run: |
sudo apt update
sudo apt install -y rpm alien tmux
sudo apt remove -y jq
- name: Set up macOS (AMD64 and ARM64)
if: runner.os == 'macOS'
run: |
brew install --quiet coreutils tree autoconf automake libtool tmux sqlite3
brew uninstall jq
# --- Build ---

- name: Build on Linux (${{ env.AMD64_LINUX_GCC }})
if: runner.os == 'Linux'
env:
PREFIX: ${{ env.AMD64_LINUX_GCC }}
CC: gcc
Expand All @@ -161,7 +146,6 @@ jobs:
./scripts/ci-create-rpm-package.sh
- name: Build on Linux (${{ env.AMD64_LINUX_CLANG }})
if: runner.os == 'Linux'
env:
PREFIX: ${{ env.AMD64_LINUX_CLANG }}
CC: clang
Expand All @@ -172,26 +156,6 @@ jobs:
./scripts/ci-create-debian-package.sh
./scripts/ci-create-rpm-package.sh
- name: Build on macOS (${{ env.AMD64_MACOSX_GCC }})
if: matrix.os == 'macos-13'
env:
PREFIX: ${{ env.AMD64_MACOSX_GCC }}
CC: gcc-13
MAKE: make
RUN_TESTS: true
run: ./scripts/ci-build.sh

- name: Build on macOS (${{ env.ARM64_MACOSX_GCC }})
if: matrix.os == 'macos-14'
env:
PREFIX: ${{ env.ARM64_MACOSX_GCC }}
CC: gcc-13
MAKE: make
RUN_TESTS: true
run: ./scripts/ci-build.sh

# --- Upload build artifacts ---

- name: Prepare build artifacts for upload
run: ./scripts/ci-prepare-artifacts-for-upload.sh

Expand All @@ -206,7 +170,6 @@ jobs:
run: ./scripts/ci-verify-attestations.sh

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.zip
Expand All @@ -217,7 +180,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip
Expand All @@ -228,7 +190,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.deb)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.deb
Expand All @@ -239,7 +200,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb
Expand All @@ -250,7 +210,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.rpm)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.rpm
Expand All @@ -261,7 +220,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm
Expand All @@ -271,30 +229,7 @@ jobs:
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
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_GCC }}.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.ARM64_MACOSX_GCC }}.zip)
if: matrix.os == 'macos-14'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.ARM64_MACOSX_GCC }}.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_LINUX_GCC }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.tar.gz
Expand All @@ -305,7 +240,6 @@ jobs:
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz
Expand All @@ -315,22 +249,75 @@ jobs:
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
- name: Upload release artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/ci-upload-release-artifacts.sh

ci-macos:
needs: [tag, clang-format, cppcheck, shellcheck]

strategy:
matrix:
os: [macos-13, macos-14]

runs-on: ${{ matrix.os }}
timeout-minutes: 30

outputs:
TAG: ${{ needs.tag.outputs.TAG }}

env:
TAG: ${{ needs.tag.outputs.TAG }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up homebrew dependencies
run: brew install --quiet coreutils tree autoconf automake libtool tmux sqlite3

- name: Set PREFIX and ZIP env var
env:
PREFIX: ${{ runner.arch == 'X64' && env.AMD64_MACOSX_GCC || env.ARM64_MACOSX_GCC }}
run: |
{
echo "PREFIX=$PREFIX"
echo "ZIP=zsv-$TAG-$PREFIX.zip"
} | tee -a "$GITHUB_ENV"
- name: Build on macOS (${{ env.AMD64_MACOSX_GCC }})
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_GCC }}.tar.gz
CC: gcc-13
MAKE: make
RUN_TESTS: true
SKIP_TAR_ARCHIVE: true
run: ./scripts/ci-build.sh

- name: Prepare build artifacts for upload
run: ./scripts/ci-prepare-artifacts-for-upload.sh

- name: Codesign and notarize (${{ env.PREFIX }})
if: startsWith(github.ref, 'refs/tags/v')
env:
MACOS_CERT_P12: ${{ secrets.MACOS_CERT_P12 }}
MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: ./scripts/ci-macos-codesign-and-notarize.sh "$PWD/$ARTIFACT_DIR/$ZIP"

- name: Attest build artifacts for release
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/attest-build-provenance@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error
subject-path: ${{ env.ARTIFACT_DIR }}/*

- name: Upload (zsv-${{ env.TAG }}-${{ env.ARM64_MACOSX_GCC }}.tar.gz)
if: matrix.os == 'macos-14'
- name: Verify attestations of release artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/ci-verify-attestations.sh

- name: Upload (${{ env.ZIP }})
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.ARM64_MACOSX_GCC }}.tar.gz
ARTIFACT_NAME: ${{ env.ZIP }}
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
Expand All @@ -341,12 +328,24 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/ci-upload-release-artifacts.sh

- name: Update homebrew tap (liquidaty/homebrew-zsv)
if: ${{ startsWith(github.ref, 'refs/tags/v') && matrix.os == 'macos-13' }}
update-homebrew-tap:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: ci-macos
runs-on: ubuntu-22.04

env:
TAG: ${{ needs.ci-macos.outputs.TAG }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
scripts/ci-update-homebrew-tap.sh
- name: Update
env:
HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
TAG: ${{ env.TAG }}
TRIPLET: ${{ env.AMD64_MACOSX_GCC }}
run: ./scripts/ci-update-homebrew-tap.sh

ci-bsd:
Expand Down Expand Up @@ -533,7 +532,7 @@ jobs:
steps:
- name: Set up dependencies
shell: sh
run: apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip
run: apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip wget tar git

- name: Checkout
uses: actions/checkout@v4
Expand All @@ -556,6 +555,14 @@ jobs:
with:
subject-path: ${{ env.ARTIFACT_DIR }}/*

- name: Set up GitHub CLI
if: startsWith(github.ref, 'refs/tags/v')
run: |
wget https://github.com/cli/cli/releases/download/v2.63.2/gh_2.63.2_linux_amd64.tar.gz
tar xvf gh_2.63.2_linux_amd64.tar.gz
cp gh_2.63.2_linux_amd64/bin/gh /usr/bin
rm -rf gh_2.63.2_linux_amd64
- name: Verify attestations of release artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/ci-verify-attestations.sh
Expand All @@ -582,7 +589,9 @@ jobs:

- name: Upload release artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/ci-upload-release-artifacts.sh
run: |
git config --global --add safe.directory "$PWD"
./scripts/ci-upload-release-artifacts.sh
ghcr:
needs: ci-musl
Expand Down Expand Up @@ -702,8 +711,8 @@ jobs:
with:
path: playground

deploy-playground:
if: ${{ github.ref_name == 'main' }}
deploy-wasm-playground:
if: ${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') }}
needs: ci-wasm
runs-on: ubuntu-22.04

Expand Down
1 change: 1 addition & 0 deletions TO-DO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v1.0 to do:
- sheet
- navigate to row: vim N-G, emacs Esc-GG
- edit cell
- save buffer to file (with or without Row # column)
- bug fixes
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ ${ZSV_UTIL_A}: ${BUILD_DIR}/objs/utils/util.a
@mkdir -p `dirname $@`
cp -p $< $@

UTIL_A_OBJ:=writer file dirs-no-jq os ${UTIL_A_OBJ_WIN}
UTIL_A_OBJ:=index writer file dirs-no-jq os ${UTIL_A_OBJ_WIN}
UTIL_A_OBJ:=$(addprefix ${BUILD_DIR}/objs/utils/,$(addsuffix .o,${UTIL_A_OBJ}))

${BUILD_DIR}/objs/utils/util.a: ${UTIL_A_OBJ}
Expand Down
5 changes: 5 additions & 0 deletions app/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ static struct zsv_ext_callbacks *zsv_ext_callbacks_init(struct zsv_ext_callbacks
e->ext_sheet_buffer_set_ctx = zsvsheet_buffer_set_ctx;
e->ext_sheet_buffer_get_ctx = zsvsheet_buffer_get_ctx;
e->ext_sheet_buffer_set_cell_attrs = zsvsheet_buffer_set_cell_attrs;
e->ext_sheet_cell_profile_attrs = zsvsheet_cell_profile_attrs;
e->ext_sheet_buffer_get_zsv_opts = zsvsheet_buffer_get_zsv_opts;
e->ext_sheet_buffer_on_newline = zsvsheet_buffer_on_newline;
e->ext_sheet_buffer_get_selected_cell = zsvsheet_buffer_get_selected_cell;
Expand Down Expand Up @@ -748,7 +749,11 @@ static struct zsv_ext *zsv_ext_new(const char *dl_name, const char *id, char ver
}
}
if (!h)
#if defined(WIN32) || defined(_WIN32)
fprintf(stderr, "Library %s not found\n", dl_name);
#else
fprintf(stderr, "Library %s failed to load: %s\n", dl_name, dlerror());
#endif

// run zsv_ext_init to add to our extension list, even if it's invalid
tmp.ok = !zsv_ext_init(h, dl_name, &tmp);
Expand Down
6 changes: 4 additions & 2 deletions app/desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,10 @@ static void zsv_desc_row(void *ctx) {
col->unique_values_ci.max_count = data->max_enum;
}

if (data->header_only)
if (data->header_only) {
data->done = 1;
zsv_abort(data->parser);
}
} else {
if (data->row_count % 50000 == 0 && data->opts->verbose)
fprintf(stderr, "%zu rows read\n", data->row_count);
Expand All @@ -423,7 +425,7 @@ const char *zsv_desc_usage_msg[] = {
"",
"Options:",
" -b,--with-bom : output with BOM",
" -C <max_num_of_columns> : maximum number of columns (default: 1024)",
" -C <max_num_of_columns> : maximum number of columns (default: " ZSV_DESC_MAX_COLS_DEFAULT_S ")",
" -H : output header names only",
" -q,--quick : minimize example counts",
" -a,--all : calculate all metadata (for now, this only adds uniqueness info)",
Expand Down
Loading

0 comments on commit 405d939

Please sign in to comment.