From 493ca3e252a9e33b2c110ad50906bc8d9fc20914 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 17 Jun 2023 15:55:48 -0700 Subject: [PATCH 01/11] Release pipeline * Group CI builds for different OSes into `ci.yml`. * Add release job to release `jq` when tag is in the format of v*. * Use `clang` as the only compiler on CI. * Provide extensible matrix for future cross-compile builds, e.g. for https://github.com/jqlang/jq/pull/2618. --- .github/workflows/ci.yml | 206 ++++++++++++++++++++++++++++++++++ .github/workflows/linux.yml | 70 ------------ .github/workflows/macos.yml | 62 ---------- .github/workflows/windows.yml | 45 -------- 4 files changed, 206 insertions(+), 177 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..f6be44110e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,206 @@ +name: CI +on: + push: + branches: + - master + tags: + - "v*" + pull_request: +jobs: + linux: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + arch: [x86_64] + include: + - arch: x86_64 + suffix: amd64 + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: true + - name: Install packages + run: | + sudo apt-get update -qq + sudo apt-get install -y \ + automake \ + autoconf \ + bison \ + flex \ + gdb \ + python3 + - name: Build + env: + CC: clang -arch ${{ matrix.arch }} + run: | + autoreconf -fi + ./configure --disable-dependency-tracking \ + --disable-silent-rules \ + --disable-maintainer-mode \ + --disable-valgrind \ + --with-oniguruma=builtin \ + YACC="$(which bison) -y" + make + make dist + cp jq jq-linux-${{ matrix.suffix }} + - name: Test + env: + CC: clang -arch ${{ matrix.arch }} + run: | + make check + - name: Upload Test Logs + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: test-logs-linux-${{ matrix.arch }} + retention-days: 7 + path: | + test-suite.log + tests/*.log + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: jq-linux-${{ matrix.suffix }} + if-no-files-found: error + retention-days: 7 + path: | + jq-linux-${{ matrix.suffix }} + macos: + runs-on: macos-13 + strategy: + fail-fast: false + matrix: + arch: [x86_64] + include: + - arch: x86_64 + suffix: amd64 + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: true + - name: Install packages + run: | + brew update + brew install \ + autoconf \ + automake \ + libtool \ + flex \ + bison + sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac + - name: Build + env: + CC: clang -arch ${{ matrix.arch }} + run: | + autoreconf -fi + ./configure --disable-dependency-tracking \ + --disable-silent-rules \ + --disable-maintainer-mode \ + --disable-valgrind \ + --with-oniguruma=builtin \ + YACC="$(brew --prefix)/opt/bison/bin/bison -y" + make + make dist + cp jq jq-macos-${{ matrix.suffix }} + - name: Test + env: + CC: clang -arch ${{ matrix.arch }} + run: | + make check + - name: Upload Test Logs + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: test-logs-macos-${{ matrix.arch }} + retention-days: 7 + path: | + test-suite.log + tests/*.log + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: jq-macos-${{ matrix.suffix }} + if-no-files-found: error + retention-days: 7 + path: | + jq-macos-${{ matrix.suffix }} + windows: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + arch: [x86_64] + include: + - arch: x86_64 + suffix: win64 + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: true + - uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + base-devel git clang autoconf automake libtool + - name: Build + shell: msys2 {0} + run: | + autoreconf -fi + ./configure --disable-dependency-tracking \ + --disable-silent-rules \ + --disable-maintainer-mode \ + --disable-valgrind \ + --with-oniguruma=builtin \ + --disable-shared \ + --enable-static \ + --enable-all-static + make + make dist + cp jq.exe jq-windows-${{ matrix.suffix }}.exe + - name: Test + shell: msys2 {0} + run: | + make SUBDIRS= "TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test" check + - name: Upload Test Logs + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: test-logs-windows-${{ matrix.arch }} + retention-days: 7 + path: | + test-suite.log + tests/*.log + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: jq-windows-${{ matrix.suffix }} + if-no-files-found: error + retention-days: 7 + path: | + jq-windows-${{ matrix.suffix }}.exe + release: + runs-on: ubuntu-latest + permissions: + contents: write + needs: [linux, macos, windows] + if: startsWith(github.event.ref, 'refs/tags/v') + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: true + - name: Merge built artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + - name: Upload release + env: + TAG_NAME: ${{ github.ref_name }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create $TAG_NAME --draft --title "jq ${TAG_NAME#v}" --generate-notes + gh release upload $TAG_NAME --clobber artifacts/jq-*/* diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 8c38da917f..0000000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Linux Build -on: - push: - branches: - - master - pull_request: -jobs: - linux: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - name: [linux-clang, linux-gcc] - include: - - name: linux-clang - os: ubuntu-22.04 - compiler: clang - cflags: '' - - name: linux-gcc - os: ubuntu-22.04 - compiler: gcc - cflags: '-Wnonnull' - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - submodules: true - - name: Install packages - run: | - sudo apt-get update -qq - sudo apt-get install -y \ - automake \ - autoconf \ - bison \ - flex \ - gdb \ - python3 \ - valgrind - - name: Build - env: - CC: ${{ matrix.compiler }} - MAKEVARS: ${{ matrix.makevars }} - run: | - autoreconf -fi - rm src/lexer.c src/lexer.h - rm src/parser.c src/parser.h - ./configure --disable-valgrind --with-oniguruma=builtin YACC="$(which bison) -y" $COVERAGE - make -j4 - make dist - - name: Test - env: - CC: ${{ matrix.compiler }} - MAKEVARS: ${{ matrix.makevars }} - run: | - ulimit -c unlimited - make -j4 check - - name: Upload Test Logs - if: ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: test-logs - path: | - test-suite.log - tests/*.log - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: jq-${{ matrix.name }} - path: | - jq diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index dcbbdb2f7f..0000000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: macOS Build -on: - push: - branches: - - master - pull_request: -jobs: - macos: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - name: [macos-12-clang, macos-13-clang] - include: - - name: macos-12-clang - os: macos-12 - compiler: clang - - name: macos-13-clang - os: macos-13 - compiler: clang - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - submodules: true - - name: Install packages - run: | - brew update - brew install autoconf automake libtool flex bison - sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac - - name: Build - env: - CC: ${{ matrix.compiler }} - MAKEVARS: ${{ matrix.makevars }} - run: | - autoreconf -fi - rm src/lexer.c src/lexer.h - rm src/parser.c src/parser.h - ./configure --disable-valgrind --with-oniguruma=builtin YACC="$(brew --prefix)/opt/bison/bin/bison -y" $COVERAGE - make -j4 - make dist - - name: Test - env: - CC: ${{ matrix.compiler }} - MAKEVARS: ${{ matrix.makevars }} - run: | - ulimit -c unlimited - make -j4 check - - name: Upload Test Logs - if: ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: test-logs - path: | - test-suite.log - tests/*.log - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: jq-${{ matrix.name }} - path: | - jq diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 04e0c8ecb6..0000000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Windows Build -on: - push: - branches: - - master - pull_request: -jobs: - windows: - runs-on: windows-latest - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - submodules: true - - uses: msys2/setup-msys2@v2 - with: - update: true - install: >- - base-devel - git - clang - autoconf - automake - libtool - p7zip - - shell: msys2 {0} - run: | - autoreconf -fiv - ./configure --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static - make -j4 - make SUBDIRS= "TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test" check - - name: Upload Test Logs - if: ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: test-logs - path: | - test-suite.log - tests/*.log - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: jq-windows - path: | - jq.exe From fc505694a74d0045c3e1046b12c1b3588c206db4 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sun, 18 Jun 2023 10:50:39 -0700 Subject: [PATCH 02/11] Locate bison for Windows build --- .github/workflows/ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6be44110e..2acbad669c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,9 +145,11 @@ jobs: with: update: true install: >- - base-devel git clang autoconf automake libtool + base-devel git clang autoconf automake libtool bison - name: Build shell: msys2 {0} + env: + CC: clang -arch ${{ matrix.arch }} run: | autoreconf -fi ./configure --disable-dependency-tracking \ @@ -157,17 +159,22 @@ jobs: --with-oniguruma=builtin \ --disable-shared \ --enable-static \ - --enable-all-static + --enable-all-static \ + YACC="$(which bison) -y" make make dist cp jq.exe jq-windows-${{ matrix.suffix }}.exe - name: Test shell: msys2 {0} run: | - make SUBDIRS= "TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test" check + make -j3 SUBDIRS= 'TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test' check + make SUBDIRS= TESTS=tests/optionaltest check || true + make SUBDIRS= TRACE_TESTS=1 TESTS=tests/shtest check || true - name: Upload Test Logs if: ${{ failure() }} uses: actions/upload-artifact@v3 + env: + CC: clang -arch ${{ matrix.arch }} with: name: test-logs-windows-${{ matrix.arch }} retention-days: 7 From b47d0162c034b4230321abc72e6312020aaa9acb Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sun, 18 Jun 2023 11:06:15 -0700 Subject: [PATCH 03/11] Also install flex for Windows build --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2acbad669c..bb48db276b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,14 @@ jobs: with: update: true install: >- - base-devel git clang autoconf automake libtool bison + base-devel + git + clang + autoconf + automake + libtool + bison + flex - name: Build shell: msys2 {0} env: From d295348dcb4e59f839d5e1263ac53af0d36802a7 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sun, 25 Jun 2023 08:43:36 -0700 Subject: [PATCH 04/11] Add matrix to test all available GH Actions images --- .github/workflows/ci.yml | 76 ++++++--------- src/jq_test.c | 196 +++++++++++++++++++++++++-------------- 2 files changed, 155 insertions(+), 117 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb48db276b..35355f6045 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,21 +1,18 @@ name: CI on: push: - branches: - - master - tags: - - "v*" pull_request: jobs: linux: - runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - arch: [x86_64] - include: - - arch: x86_64 - suffix: amd64 + compiler: [gcc, clang] + image: [ubuntu-20.04, ubuntu-22.04] + runs-on: ${{ matrix.image }} + env: + CC: ${{ matrix.compiler }} + SUFFIX: linux-${{ matrix.image}}-${{ matrix.compiler }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -32,8 +29,6 @@ jobs: gdb \ python3 - name: Build - env: - CC: clang -arch ${{ matrix.arch }} run: | autoreconf -fi ./configure --disable-dependency-tracking \ @@ -43,18 +38,15 @@ jobs: --with-oniguruma=builtin \ YACC="$(which bison) -y" make - make dist - cp jq jq-linux-${{ matrix.suffix }} + cp jq jq-${{ env.SUFFIX }} - name: Test - env: - CC: clang -arch ${{ matrix.arch }} run: | make check - name: Upload Test Logs if: ${{ failure() }} uses: actions/upload-artifact@v3 with: - name: test-logs-linux-${{ matrix.arch }} + name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | test-suite.log @@ -62,20 +54,21 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: jq-linux-${{ matrix.suffix }} + name: jq-${{ env.SUFFIX }} if-no-files-found: error retention-days: 7 path: | - jq-linux-${{ matrix.suffix }} + jq-${{ env.SUFFIX }} macos: - runs-on: macos-13 strategy: fail-fast: false matrix: - arch: [x86_64] - include: - - arch: x86_64 - suffix: amd64 + compiler: [gcc, clang] + image: [macos-11, macos-12, macos-13] + runs-on: ${{ matrix.image }} + env: + CC: ${{ matrix.compiler }} + SUFFIX: macos-${{ matrix.image}}-${{ matrix.compiler }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -92,8 +85,6 @@ jobs: bison sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac - name: Build - env: - CC: clang -arch ${{ matrix.arch }} run: | autoreconf -fi ./configure --disable-dependency-tracking \ @@ -103,18 +94,15 @@ jobs: --with-oniguruma=builtin \ YACC="$(brew --prefix)/opt/bison/bin/bison -y" make - make dist - cp jq jq-macos-${{ matrix.suffix }} + cp jq jq-${{ env.SUFFIX }} - name: Test - env: - CC: clang -arch ${{ matrix.arch }} run: | make check - name: Upload Test Logs if: ${{ failure() }} uses: actions/upload-artifact@v3 with: - name: test-logs-macos-${{ matrix.arch }} + name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | test-suite.log @@ -122,20 +110,21 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: jq-macos-${{ matrix.suffix }} + name: jq-${{ env.SUFFIX }} if-no-files-found: error retention-days: 7 path: | - jq-macos-${{ matrix.suffix }} + jq-${{ env.SUFFIX }} windows: - runs-on: windows-latest strategy: fail-fast: false matrix: - arch: [x86_64] - include: - - arch: x86_64 - suffix: win64 + compiler: [gcc] + image: [windows-2019, windows-2022] + runs-on: ${{ matrix.image }} + env: + CC: ${{ matrix.compiler }} + SUFFIX: windows-${{ matrix.image}}-${{ matrix.compiler }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -155,8 +144,6 @@ jobs: flex - name: Build shell: msys2 {0} - env: - CC: clang -arch ${{ matrix.arch }} run: | autoreconf -fi ./configure --disable-dependency-tracking \ @@ -169,8 +156,7 @@ jobs: --enable-all-static \ YACC="$(which bison) -y" make - make dist - cp jq.exe jq-windows-${{ matrix.suffix }}.exe + cp jq.exe jq-${{ env.SUFFIX }}.exe - name: Test shell: msys2 {0} run: | @@ -180,10 +166,8 @@ jobs: - name: Upload Test Logs if: ${{ failure() }} uses: actions/upload-artifact@v3 - env: - CC: clang -arch ${{ matrix.arch }} with: - name: test-logs-windows-${{ matrix.arch }} + name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | test-suite.log @@ -191,11 +175,11 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: jq-windows-${{ matrix.suffix }} + name: jq-${{ env.SUFFIX }} if-no-files-found: error retention-days: 7 path: | - jq-windows-${{ matrix.suffix }}.exe + jq-${{ env.SUFFIX }}.exe release: runs-on: ubuntu-latest permissions: diff --git a/src/jq_test.c b/src/jq_test.c index eed633f43d..f7cebbe7e6 100644 --- a/src/jq_test.c +++ b/src/jq_test.c @@ -8,23 +8,31 @@ static void jv_test(); static void run_jq_tests(jv, int, FILE *, int, int); - -int jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) { +int jq_testsuite(jv libdirs, int verbose, int argc, char *argv[]) +{ FILE *testdata = stdin; int skip = -1; int take = -1; jv_test(); - if (argc > 0) { - for(int i = 0; i < argc; i++) { - if (!strcmp(argv[i], "--skip")) { - skip = atoi(argv[i+1]); + if (argc > 0) + { + for (int i = 0; i < argc; i++) + { + if (!strcmp(argv[i], "--skip")) + { + skip = atoi(argv[i + 1]); i++; - } else if (!strcmp(argv[i], "--take")) { - take = atoi(argv[i+1]); + } + else if (!strcmp(argv[i], "--take")) + { + take = atoi(argv[i + 1]); i++; - } else { + } + else + { testdata = fopen(argv[i], "r"); - if (!testdata) { + if (!testdata) + { perror("fopen"); exit(1); } @@ -35,26 +43,33 @@ int jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) { return 0; } -static int skipline(const char* buf) { +static int skipline(const char *buf) +{ int p = 0; - while (buf[p] == ' ' || buf[p] == '\t') p++; - if (buf[p] == '#' || buf[p] == '\n' || buf[p] == 0) return 1; + while (buf[p] == ' ' || buf[p] == '\t') + p++; + if (buf[p] == '#' || buf[p] == '\n' || buf[p] == 0) + return 1; return 0; } -static int checkerrormsg(const char* buf) { +static int checkerrormsg(const char *buf) +{ return strcmp(buf, "%%FAIL\n") == 0; } -static int checkfail(const char* buf) { +static int checkfail(const char *buf) +{ return strcmp(buf, "%%FAIL\n") == 0 || strcmp(buf, "%%FAIL IGNORE MSG\n") == 0; } -struct err_data { +struct err_data +{ char buf[4096]; }; -static void test_err_cb(void *data, jv e) { +static void test_err_cb(void *data, jv e) +{ struct err_data *err_data = data; if (jv_get_kind(e) != JV_KIND_STRING) e = jv_dump_string(e, JV_PRINT_INVALID); @@ -65,7 +80,8 @@ static void test_err_cb(void *data, jv e) { jv_free(e); } -static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int take) { +static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int take) +{ char prog[4096]; char buf[4096]; struct err_data err_msg; @@ -84,40 +100,52 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int lib_dirs = jv_array(); jq_set_attr(jq, jv_string("JQ_LIBRARY_PATH"), lib_dirs); - while (1) { - if (!fgets(prog, sizeof(prog), testdata)) break; + while (1) + { + if (!fgets(prog, sizeof(prog), testdata)) + break; lineno++; - if (skipline(prog)) continue; - if (checkfail(prog)) { + if (skipline(prog)) + continue; + if (checkfail(prog)) + { must_fail = 1; check_msg = checkerrormsg(prog); jq_set_error_cb(jq, test_err_cb, &err_msg); continue; } - if (prog[strlen(prog)-1] == '\n') prog[strlen(prog)-1] = 0; + if (prog[strlen(prog) - 1] == '\n') + prog[strlen(prog) - 1] = 0; - if (skip > 0) { + if (skip > 0) + { skip--; // skip past test data - while (fgets(buf, sizeof(buf), testdata)) { + while (fgets(buf, sizeof(buf), testdata)) + { lineno++; if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n')) break; } - + must_fail = 0; check_msg = 0; continue; - } else if (skip == 0) { + } + else if (skip == 0) + { printf("Skipped %d tests\n", tests_to_skip); skip = -1; } - if (take > 0) { + if (take > 0) + { take--; - } else if (take == 0) { + } + else if (take == 0) + { printf("Hit the number of tests limit (%d), breaking\n", tests_to_take); take = -1; break; @@ -128,22 +156,32 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int printf("Test #%d: '%s' at line number %u\n", tests + tests_to_skip, prog, lineno); int compiled = jq_compile(jq, prog); - if (must_fail) { + if (must_fail) + { jq_set_error_cb(jq, NULL, NULL); - if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; } + if (!fgets(buf, sizeof(buf), testdata)) + { + invalid++; + break; + } lineno++; - if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0; - if (compiled) { + if (buf[strlen(buf) - 1] == '\n') + buf[strlen(buf) - 1] = 0; + if (compiled) + { printf("*** Test program compiled that should not have at line %u: %s\n", lineno, prog); must_fail = 0; check_msg = 0; invalid++; continue; } - if (check_msg && strcmp(buf, err_msg.buf) != 0) { + if (check_msg && strcmp(buf, err_msg.buf) != 0) + { printf("*** Erroneous test program failed with wrong message (%s) at line %u: %s\n", err_msg.buf, lineno, prog); invalid++; - } else { + } + else + { passed++; } must_fail = 0; @@ -151,48 +189,62 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int continue; } - if (!compiled) { + if (!compiled) + { printf("*** Test program failed to compile at line %u: %s\n", lineno, prog); invalid++; // skip past test data - while (fgets(buf, sizeof(buf), testdata)) { + while (fgets(buf, sizeof(buf), testdata)) + { lineno++; if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n')) break; } continue; } - if (verbose) { + if (verbose) + { printf("Disassembly:\n"); jq_dump_disassembly(jq, 2); printf("\n"); } - if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; } + if (!fgets(buf, sizeof(buf), testdata)) + { + invalid++; + break; + } lineno++; jv input = jv_parse(buf); - if (!jv_is_valid(input)) { + if (!jv_is_valid(input)) + { printf("*** Input is invalid on line %u: %s\n", lineno, buf); invalid++; continue; } jq_start(jq, input, verbose ? JQ_DEBUG_TRACE : 0); - while (fgets(buf, sizeof(buf), testdata)) { + while (fgets(buf, sizeof(buf), testdata)) + { lineno++; - if (skipline(buf)) break; + if (skipline(buf)) + break; jv expected = jv_parse(buf); - if (!jv_is_valid(expected)) { + if (!jv_is_valid(expected)) + { printf("*** Expected result is invalid on line %u: %s\n", lineno, buf); invalid++; continue; } jv actual = jq_next(jq); - if (!jv_is_valid(actual)) { + if (!jv_is_valid(actual)) + { jv_free(actual); printf("*** Insufficient results for test at line number %u: %s\n", lineno, prog); pass = 0; break; - } else if (!jv_equal(jv_copy(expected), jv_copy(actual))) { + } + else if (!jv_equal(jv_copy(expected), jv_copy(actual))) + { printf("*** Expected "); jv_dump(jv_copy(expected), 0); printf(", but got "); @@ -200,7 +252,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int printf(" for test at line number %u: %s\n", lineno, prog); pass = 0; } - jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT)); + jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR | JV_PRINT_REFCOUNT)); jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string))); assert(jv_equal(jv_copy(expected), jv_copy(reparsed))); jv_free(as_string); @@ -208,40 +260,47 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int jv_free(expected); jv_free(actual); } - if (pass) { + if (pass) + { jv extra = jq_next(jq); - if (jv_is_valid(extra)) { + if (jv_is_valid(extra)) + { printf("*** Superfluous result: "); jv_dump(extra, 0); printf(" for test at line number %u, %s\n", lineno, prog); pass = 0; - } else { + } + else + { jv_free(extra); } } - passed+=pass; + passed += pass; } jq_teardown(&jq); int total_skipped = tests_to_skip; - if (skip > 0) { + if (skip > 0) + { total_skipped = tests_to_skip - skip; } - printf("%d of %d tests passed (%d malformed, %d skipped)\n", - passed, tests, invalid, total_skipped); + printf("%d of %d tests passed (%d malformed, %d skipped)\n", + passed, tests, invalid, total_skipped); - if (skip > 0) { + if (skip > 0) + { printf("WARN: skipped past the end of file, exiting with status 2\n"); exit(2); } - if (passed != tests) exit(1); + if (passed != tests) + exit(1); } - -static void jv_test() { +static void jv_test() +{ /// JSON parser regression tests { jv v = jv_parse("{\"a':\"12\"}"); @@ -273,7 +332,6 @@ static void jv_test() { assert(!jv_equal(jv_copy(a2), jv_copy(a))); jv_free(a2); - assert(jv_get_refcnt(a) == 1); a = jv_array_append(a, jv_copy(a)); assert(jv_get_refcnt(a) == 1); @@ -281,7 +339,8 @@ static void jv_test() { assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); - for (int i=0; i<10; i++) { + for (int i = 0; i < 10; i++) + { jv subarray = jv_array_get(jv_copy(a), 1); assert(jv_get_kind(subarray) == JV_KIND_ARRAY); assert(jv_array_length(jv_copy(subarray)) == 1); @@ -289,7 +348,6 @@ static void jv_test() { jv_free(subarray); } - jv subarray = jv_array_get(jv_copy(a), 1); assert(jv_get_kind(subarray) == JV_KIND_ARRAY); assert(jv_array_length(jv_copy(subarray)) == 1); @@ -309,9 +367,9 @@ static void jv_test() { jv_free(subarray); - void* before = sub2.u.ptr; + void *before = sub2.u.ptr; sub2 = jv_array_append(sub2, jv_number(200)); - void* after = sub2.u.ptr; + void *after = sub2.u.ptr; assert(before == after); jv_free(sub2); @@ -322,7 +380,6 @@ static void jv_test() { assert(jv_number_value(jv_array_get(jv_copy(a3), 2)) == 19); jv_free(a3); - jv a4 = jv_array(); a4 = jv_array_append(a4, jv_number(1)); a4 = jv_array_append(a4, jv_number(2)); @@ -336,17 +393,14 @@ static void jv_test() { jv_free(a4); jv_free(a5); - assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); assert(jv_array_length(jv_array_get(jv_copy(a), 1)) == 1); - - //jv_dump(jv_copy(a), 0); printf("\n"); + // jv_dump(jv_copy(a), 0); printf("\n"); jv_free(a); } - /// Strings { assert(jv_equal(jv_string("foo"), jv_string_sized("foo", 3))); @@ -357,7 +411,6 @@ static void jv_test() { jv_free(shortstr); jv_free(longstr); - char a1s[] = "hello", a2s[] = "hello", bs[] = "goodbye"; jv a1 = jv_string(a1s), a2 = jv_string(a2s), b = jv_string(bs); assert(jv_equal(jv_copy(a1), jv_copy(a2))); @@ -373,8 +426,9 @@ static void jv_test() { assert(jv_equal(jv_string("hello42!"), jv_string_fmt("hello%d%s", 42, "!"))); char big[20000]; - for (int i=0; i<(int)sizeof(big); i++) big[i] = 'a'; - big[sizeof(big)-1] = 0; + for (int i = 0; i < (int)sizeof(big); i++) + big[i] = 'a'; + big[sizeof(big) - 1] = 0; jv str = jv_string_fmt("%s", big); assert(jv_string_length_bytes(jv_copy(str)) == sizeof(big) - 1); assert(!strcmp(big, jv_string_value(str))); @@ -397,7 +451,7 @@ static void jv_test() { jv_free(o1); assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string("bar"))) == 240); - //jv_dump(jv_copy(o2), 0); printf("\n"); + // jv_dump(jv_copy(o2), 0); printf("\n"); jv_free(o2); } } From 4c15a17bf6d75b3eb9881382b38f9ae898f9ab60 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 10:46:25 -0700 Subject: [PATCH 05/11] Enable all tests for Windows --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35355f6045..29cdb264de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,9 +160,7 @@ jobs: - name: Test shell: msys2 {0} run: | - make -j3 SUBDIRS= 'TESTS=tests/mantest tests/jqtest tests/onigtest tests/base64test' check - make SUBDIRS= TESTS=tests/optionaltest check || true - make SUBDIRS= TRACE_TESTS=1 TESTS=tests/shtest check || true + make check - name: Upload Test Logs if: ${{ failure() }} uses: actions/upload-artifact@v3 From 25a0608a646e0674de1347f68b947502608fa86e Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 10:50:55 -0700 Subject: [PATCH 06/11] Run `brew update-reset` when `brew update` fails `brew update` can fail for "Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!" Ref: https://github.com/owenthereal/jq/actions/runs/5432314910/jobs/9879266028#step:3:19 --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29cdb264de..115cd7a742 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,8 @@ jobs: submodules: true - name: Install packages run: | - brew update + # brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!" + brew update || brew update-reset brew install \ autoconf \ automake \ From 6cce62dfa9f402849a066185414c5cb7ab45cee3 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 11:01:50 -0700 Subject: [PATCH 07/11] Select gcc binaries to release --- .github/workflows/ci.yml | 16 ++-- src/jq_test.c | 196 ++++++++++++++------------------------- 2 files changed, 80 insertions(+), 132 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 115cd7a742..1e22e6e906 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,6 @@ jobs: --with-oniguruma=builtin \ YACC="$(which bison) -y" make - cp jq jq-${{ env.SUFFIX }} - name: Test run: | make check @@ -58,7 +57,7 @@ jobs: if-no-files-found: error retention-days: 7 path: | - jq-${{ env.SUFFIX }} + jq macos: strategy: fail-fast: false @@ -95,7 +94,6 @@ jobs: --with-oniguruma=builtin \ YACC="$(brew --prefix)/opt/bison/bin/bison -y" make - cp jq jq-${{ env.SUFFIX }} - name: Test run: | make check @@ -115,7 +113,7 @@ jobs: if-no-files-found: error retention-days: 7 path: | - jq-${{ env.SUFFIX }} + jq windows: strategy: fail-fast: false @@ -157,7 +155,6 @@ jobs: --enable-all-static \ YACC="$(which bison) -y" make - cp jq.exe jq-${{ env.SUFFIX }}.exe - name: Test shell: msys2 {0} run: | @@ -178,7 +175,7 @@ jobs: if-no-files-found: error retention-days: 7 path: | - jq-${{ env.SUFFIX }}.exe + jq.exe release: runs-on: ubuntu-latest permissions: @@ -199,5 +196,10 @@ jobs: TAG_NAME: ${{ github.ref_name }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + mkdir release + cp artifacts/jq-linux-ubuntu-22.04-gcc/jq release/jq-linux-amd64 + cp artifacts/jq-macos-macos-13-gcc/jq release/jq-macos-amd64 + cp artifacts/jq-windows-windows-2022-gcc/jq.exe release/jq-windows-amd64.exe + gh release create $TAG_NAME --draft --title "jq ${TAG_NAME#v}" --generate-notes - gh release upload $TAG_NAME --clobber artifacts/jq-*/* + gh release upload $TAG_NAME --clobber release/jq-* diff --git a/src/jq_test.c b/src/jq_test.c index f7cebbe7e6..eed633f43d 100644 --- a/src/jq_test.c +++ b/src/jq_test.c @@ -8,31 +8,23 @@ static void jv_test(); static void run_jq_tests(jv, int, FILE *, int, int); -int jq_testsuite(jv libdirs, int verbose, int argc, char *argv[]) -{ + +int jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) { FILE *testdata = stdin; int skip = -1; int take = -1; jv_test(); - if (argc > 0) - { - for (int i = 0; i < argc; i++) - { - if (!strcmp(argv[i], "--skip")) - { - skip = atoi(argv[i + 1]); + if (argc > 0) { + for(int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--skip")) { + skip = atoi(argv[i+1]); i++; - } - else if (!strcmp(argv[i], "--take")) - { - take = atoi(argv[i + 1]); + } else if (!strcmp(argv[i], "--take")) { + take = atoi(argv[i+1]); i++; - } - else - { + } else { testdata = fopen(argv[i], "r"); - if (!testdata) - { + if (!testdata) { perror("fopen"); exit(1); } @@ -43,33 +35,26 @@ int jq_testsuite(jv libdirs, int verbose, int argc, char *argv[]) return 0; } -static int skipline(const char *buf) -{ +static int skipline(const char* buf) { int p = 0; - while (buf[p] == ' ' || buf[p] == '\t') - p++; - if (buf[p] == '#' || buf[p] == '\n' || buf[p] == 0) - return 1; + while (buf[p] == ' ' || buf[p] == '\t') p++; + if (buf[p] == '#' || buf[p] == '\n' || buf[p] == 0) return 1; return 0; } -static int checkerrormsg(const char *buf) -{ +static int checkerrormsg(const char* buf) { return strcmp(buf, "%%FAIL\n") == 0; } -static int checkfail(const char *buf) -{ +static int checkfail(const char* buf) { return strcmp(buf, "%%FAIL\n") == 0 || strcmp(buf, "%%FAIL IGNORE MSG\n") == 0; } -struct err_data -{ +struct err_data { char buf[4096]; }; -static void test_err_cb(void *data, jv e) -{ +static void test_err_cb(void *data, jv e) { struct err_data *err_data = data; if (jv_get_kind(e) != JV_KIND_STRING) e = jv_dump_string(e, JV_PRINT_INVALID); @@ -80,8 +65,7 @@ static void test_err_cb(void *data, jv e) jv_free(e); } -static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int take) -{ +static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int take) { char prog[4096]; char buf[4096]; struct err_data err_msg; @@ -100,52 +84,40 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int lib_dirs = jv_array(); jq_set_attr(jq, jv_string("JQ_LIBRARY_PATH"), lib_dirs); - while (1) - { - if (!fgets(prog, sizeof(prog), testdata)) - break; + while (1) { + if (!fgets(prog, sizeof(prog), testdata)) break; lineno++; - if (skipline(prog)) - continue; - if (checkfail(prog)) - { + if (skipline(prog)) continue; + if (checkfail(prog)) { must_fail = 1; check_msg = checkerrormsg(prog); jq_set_error_cb(jq, test_err_cb, &err_msg); continue; } - if (prog[strlen(prog) - 1] == '\n') - prog[strlen(prog) - 1] = 0; + if (prog[strlen(prog)-1] == '\n') prog[strlen(prog)-1] = 0; - if (skip > 0) - { + if (skip > 0) { skip--; // skip past test data - while (fgets(buf, sizeof(buf), testdata)) - { + while (fgets(buf, sizeof(buf), testdata)) { lineno++; if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n')) break; } - + must_fail = 0; check_msg = 0; continue; - } - else if (skip == 0) - { + } else if (skip == 0) { printf("Skipped %d tests\n", tests_to_skip); skip = -1; } - if (take > 0) - { + if (take > 0) { take--; - } - else if (take == 0) - { + } else if (take == 0) { printf("Hit the number of tests limit (%d), breaking\n", tests_to_take); take = -1; break; @@ -156,32 +128,22 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int printf("Test #%d: '%s' at line number %u\n", tests + tests_to_skip, prog, lineno); int compiled = jq_compile(jq, prog); - if (must_fail) - { + if (must_fail) { jq_set_error_cb(jq, NULL, NULL); - if (!fgets(buf, sizeof(buf), testdata)) - { - invalid++; - break; - } + if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; } lineno++; - if (buf[strlen(buf) - 1] == '\n') - buf[strlen(buf) - 1] = 0; - if (compiled) - { + if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0; + if (compiled) { printf("*** Test program compiled that should not have at line %u: %s\n", lineno, prog); must_fail = 0; check_msg = 0; invalid++; continue; } - if (check_msg && strcmp(buf, err_msg.buf) != 0) - { + if (check_msg && strcmp(buf, err_msg.buf) != 0) { printf("*** Erroneous test program failed with wrong message (%s) at line %u: %s\n", err_msg.buf, lineno, prog); invalid++; - } - else - { + } else { passed++; } must_fail = 0; @@ -189,62 +151,48 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int continue; } - if (!compiled) - { + if (!compiled) { printf("*** Test program failed to compile at line %u: %s\n", lineno, prog); invalid++; // skip past test data - while (fgets(buf, sizeof(buf), testdata)) - { + while (fgets(buf, sizeof(buf), testdata)) { lineno++; if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n')) break; } continue; } - if (verbose) - { + if (verbose) { printf("Disassembly:\n"); jq_dump_disassembly(jq, 2); printf("\n"); } - if (!fgets(buf, sizeof(buf), testdata)) - { - invalid++; - break; - } + if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; } lineno++; jv input = jv_parse(buf); - if (!jv_is_valid(input)) - { + if (!jv_is_valid(input)) { printf("*** Input is invalid on line %u: %s\n", lineno, buf); invalid++; continue; } jq_start(jq, input, verbose ? JQ_DEBUG_TRACE : 0); - while (fgets(buf, sizeof(buf), testdata)) - { + while (fgets(buf, sizeof(buf), testdata)) { lineno++; - if (skipline(buf)) - break; + if (skipline(buf)) break; jv expected = jv_parse(buf); - if (!jv_is_valid(expected)) - { + if (!jv_is_valid(expected)) { printf("*** Expected result is invalid on line %u: %s\n", lineno, buf); invalid++; continue; } jv actual = jq_next(jq); - if (!jv_is_valid(actual)) - { + if (!jv_is_valid(actual)) { jv_free(actual); printf("*** Insufficient results for test at line number %u: %s\n", lineno, prog); pass = 0; break; - } - else if (!jv_equal(jv_copy(expected), jv_copy(actual))) - { + } else if (!jv_equal(jv_copy(expected), jv_copy(actual))) { printf("*** Expected "); jv_dump(jv_copy(expected), 0); printf(", but got "); @@ -252,7 +200,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int printf(" for test at line number %u: %s\n", lineno, prog); pass = 0; } - jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR | JV_PRINT_REFCOUNT)); + jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT)); jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string))); assert(jv_equal(jv_copy(expected), jv_copy(reparsed))); jv_free(as_string); @@ -260,47 +208,40 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int jv_free(expected); jv_free(actual); } - if (pass) - { + if (pass) { jv extra = jq_next(jq); - if (jv_is_valid(extra)) - { + if (jv_is_valid(extra)) { printf("*** Superfluous result: "); jv_dump(extra, 0); printf(" for test at line number %u, %s\n", lineno, prog); pass = 0; - } - else - { + } else { jv_free(extra); } } - passed += pass; + passed+=pass; } jq_teardown(&jq); int total_skipped = tests_to_skip; - if (skip > 0) - { + if (skip > 0) { total_skipped = tests_to_skip - skip; } - printf("%d of %d tests passed (%d malformed, %d skipped)\n", - passed, tests, invalid, total_skipped); + printf("%d of %d tests passed (%d malformed, %d skipped)\n", + passed, tests, invalid, total_skipped); - if (skip > 0) - { + if (skip > 0) { printf("WARN: skipped past the end of file, exiting with status 2\n"); exit(2); } - if (passed != tests) - exit(1); + if (passed != tests) exit(1); } -static void jv_test() -{ + +static void jv_test() { /// JSON parser regression tests { jv v = jv_parse("{\"a':\"12\"}"); @@ -332,6 +273,7 @@ static void jv_test() assert(!jv_equal(jv_copy(a2), jv_copy(a))); jv_free(a2); + assert(jv_get_refcnt(a) == 1); a = jv_array_append(a, jv_copy(a)); assert(jv_get_refcnt(a) == 1); @@ -339,8 +281,7 @@ static void jv_test() assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); - for (int i = 0; i < 10; i++) - { + for (int i=0; i<10; i++) { jv subarray = jv_array_get(jv_copy(a), 1); assert(jv_get_kind(subarray) == JV_KIND_ARRAY); assert(jv_array_length(jv_copy(subarray)) == 1); @@ -348,6 +289,7 @@ static void jv_test() jv_free(subarray); } + jv subarray = jv_array_get(jv_copy(a), 1); assert(jv_get_kind(subarray) == JV_KIND_ARRAY); assert(jv_array_length(jv_copy(subarray)) == 1); @@ -367,9 +309,9 @@ static void jv_test() jv_free(subarray); - void *before = sub2.u.ptr; + void* before = sub2.u.ptr; sub2 = jv_array_append(sub2, jv_number(200)); - void *after = sub2.u.ptr; + void* after = sub2.u.ptr; assert(before == after); jv_free(sub2); @@ -380,6 +322,7 @@ static void jv_test() assert(jv_number_value(jv_array_get(jv_copy(a3), 2)) == 19); jv_free(a3); + jv a4 = jv_array(); a4 = jv_array_append(a4, jv_number(1)); a4 = jv_array_append(a4, jv_number(2)); @@ -393,14 +336,17 @@ static void jv_test() jv_free(a4); jv_free(a5); + assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); assert(jv_array_length(jv_array_get(jv_copy(a), 1)) == 1); - // jv_dump(jv_copy(a), 0); printf("\n"); + + //jv_dump(jv_copy(a), 0); printf("\n"); jv_free(a); } + /// Strings { assert(jv_equal(jv_string("foo"), jv_string_sized("foo", 3))); @@ -411,6 +357,7 @@ static void jv_test() jv_free(shortstr); jv_free(longstr); + char a1s[] = "hello", a2s[] = "hello", bs[] = "goodbye"; jv a1 = jv_string(a1s), a2 = jv_string(a2s), b = jv_string(bs); assert(jv_equal(jv_copy(a1), jv_copy(a2))); @@ -426,9 +373,8 @@ static void jv_test() assert(jv_equal(jv_string("hello42!"), jv_string_fmt("hello%d%s", 42, "!"))); char big[20000]; - for (int i = 0; i < (int)sizeof(big); i++) - big[i] = 'a'; - big[sizeof(big) - 1] = 0; + for (int i=0; i<(int)sizeof(big); i++) big[i] = 'a'; + big[sizeof(big)-1] = 0; jv str = jv_string_fmt("%s", big); assert(jv_string_length_bytes(jv_copy(str)) == sizeof(big) - 1); assert(!strcmp(big, jv_string_value(str))); @@ -451,7 +397,7 @@ static void jv_test() jv_free(o1); assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string("bar"))) == 240); - // jv_dump(jv_copy(o2), 0); printf("\n"); + //jv_dump(jv_copy(o2), 0); printf("\n"); jv_free(o2); } } From 69e27dde737bd258522d3b07528efe63d7aaef9d Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 12:03:29 -0700 Subject: [PATCH 08/11] Only enable CI when push to master & tag --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e22e6e906..4b5bb1f193 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI on: push: + branches: + - master + tags: + - "v*" pull_request: jobs: linux: From 2480dd2522cfbdf36dd1b7be287b82b74bb07cf3 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 12:09:01 -0700 Subject: [PATCH 09/11] Try out statick build --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b5bb1f193..7c6af5d6c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,8 @@ jobs: --disable-maintainer-mode \ --disable-valgrind \ --with-oniguruma=builtin \ + --enable-static \ + --enable-all-static \ YACC="$(which bison) -y" make - name: Test @@ -96,6 +98,8 @@ jobs: --disable-maintainer-mode \ --disable-valgrind \ --with-oniguruma=builtin \ + --enable-static \ + --enable-all-static \ YACC="$(brew --prefix)/opt/bison/bin/bison -y" make - name: Test From 4a4ba8834771c8390dc31fb0f75397f2276fa034 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 12:55:59 -0700 Subject: [PATCH 10/11] No need to enforce the same `AM_INIT_AUTOMAKE` version for MacOS --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c6af5d6c7..1ff5c8dfeb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,6 @@ jobs: libtool \ flex \ bison - sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac - name: Build run: | autoreconf -fi From 65202425d3bbf62795a50ae20d5c10a536ab0a24 Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Sat, 1 Jul 2023 13:01:03 -0700 Subject: [PATCH 11/11] Disable static build for ubuntu-20.04 See https://github.com/jqlang/jq/pull/2620#discussion_r1248936822 --- .github/workflows/ci.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ff5c8dfeb..b682b11bbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,19 @@ jobs: matrix: compiler: [gcc, clang] image: [ubuntu-20.04, ubuntu-22.04] + include: + - compiler: gcc + image: ubuntu-20.04 + configure_flag: '' + - compiler: gcc + image: ubuntu-22.04 + configure_flag: --enable-static --enable-all-static + - compiler: clang + image: ubuntu-20.04 + configure_flag: '' + - compiler: clang + image: ubuntu-22.04 + configure_flag: --enable-static --enable-all-static runs-on: ${{ matrix.image }} env: CC: ${{ matrix.compiler }} @@ -40,8 +53,7 @@ jobs: --disable-maintainer-mode \ --disable-valgrind \ --with-oniguruma=builtin \ - --enable-static \ - --enable-all-static \ + ${{ matrix.configure_flag }} \ YACC="$(which bison) -y" make - name: Test