From b001c76434145350b4e4baa0e78e46188c852081 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Fri, 22 Oct 2021 05:04:57 -0700 Subject: [PATCH 01/34] Add Dockerfile and Docker usage instructions * Added Dockerfile to build minimal, multi-stage image * Updated README with build instructions Recording of local build/test: https://asciinema.org/a/Ql7Xc5fgxxvkFrjjcuMbR0npY Currently builds image size 85.8MB from local build on macOS ``` docker images REPOSITORY TAG IMAGE ID CREATED SIZE ion-cli 0.1.1 e81a9d863b95 49 minutes ago 85.8MB ``` --- .dockerignore | 8 ++++++++ Dockerfile | 13 +++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..8b160ccc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +/target +/.idea + +*.md + +Dockerfile +LICENSE +NOTICE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3017ee6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM rust:1.56-slim as builder +ENV builddeps="cmake git gcc g++ clang" +WORKDIR /usr/src/ion-cli +COPY . . +RUN apt-get update -y \ + && apt-get install -y ${builddeps} \ + && git submodule update --init --recursive +RUN cargo install --path . + +FROM debian:11.1-slim +COPY --from=builder /usr/local/cargo/bin/ion /usr/bin/ion +CMD /usr/bin/ion +VOLUME /data diff --git a/README.md b/README.md index dc3b7447..5a1d967c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,39 @@ and the API is subject to change._ ion help ``` +### Docker Instructions + +1. Clone the repository (recursive clone not necessary) + ``` + git clone https://github.com/amzn/ion-cli.git + ``` +2. Step into the newly created directory + ``` + cd ion-cli + ``` +3. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) +4. Build and run the image + ``` + # build the image + docker build -t : . + + + # run the CLI binary inside the Docker image + docker run -it --rm [optional flags...] : ion + + # examples: + + # build docker image with current release version + docker build -t ion-cli:0.1.1 . + + # print the help message + docker run -it --rm ion-cli:0.1.1 ion -V + + # mount current directory to /data volume and dump an ion file + docker run -it --rm -v $PWD:/data ion-cli:0.1.1 ion dump /data/test.ion + + ``` + ## Security See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. From 37bbc9b597b428ba0503bd5fbac365b1620d4372 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Fri, 22 Oct 2021 05:27:29 -0700 Subject: [PATCH 02/34] Remove unnecessary gcc, g++ deps in builder img --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3017ee6e..0cb18121 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56-slim as builder -ENV builddeps="cmake git gcc g++ clang" +ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From 3d384f24bdc7d5c0446cd29a838d137d34a5704b Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:38:53 -0700 Subject: [PATCH 03/34] Add build workflow, cleanup README --- .github/workflows/verify-docker-build.yml | 26 +++++++++++++++++++++++ Dockerfile | 2 +- README.md | 8 +++---- 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/verify-docker-build.yml diff --git a/.github/workflows/verify-docker-build.yml b/.github/workflows/verify-docker-build.yml new file mode 100644 index 00000000..4a9e4038 --- /dev/null +++ b/.github/workflows/verify-docker-build.yml @@ -0,0 +1,26 @@ +name: Verify Docker image builds +on: + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + push_to_registry: + name: Build docker image + runs-on: ubuntu-20.04 + steps: + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Setup Docker buildx + uses: docker/setup-buildx-action@v1 + - + name: Build image + run: docker buildx build -t ion-cli:test-build . + + diff --git a/Dockerfile b/Dockerfile index 0cb18121..faad53e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.56-slim as builder +FROM rust:1.56.1-slim-buster as builder ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . diff --git a/README.md b/README.md index 5a1d967c..9e6a0cbb 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ and the API is subject to change._ ``` This will put a copy of the `ion` executable in `~/.cargo/bin`. - **If this step fails:** You're likely missing one of `ion-c`'s dependencies. Make sure you have `cmake`, `gcc`, `g++`, and `libc++` installed. + **If this step fails:** You're likely missing one of `ion-c`'s dependencies. Make sure you have `cmake` and `clang` installed. 5. Confirm that `~/.cargo/bin` is on your `$PATH`. `rustup` will probably take care of this for you. @@ -35,15 +35,15 @@ and the API is subject to change._ ### Docker Instructions -1. Clone the repository (recursive clone not necessary) +1. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) +2. Clone the repository (recursive clone not necessary) ``` git clone https://github.com/amzn/ion-cli.git ``` -2. Step into the newly created directory +3. Step into the newly created directory ``` cd ion-cli ``` -3. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) 4. Build and run the image ``` # build the image From 5126b11c76cff3d256ef28e0f13cbdfb9400b1c8 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:48:52 -0700 Subject: [PATCH 04/34] Test: intentionally break build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index faad53e6..1a66ecd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56.1-slim-buster as builder -ENV builddeps="cmake git clang" +ENV builddeps="cmake git" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From 16cf2b2732a14d83326527df5ce0bf6aad6990bb Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:52:37 -0700 Subject: [PATCH 05/34] Fix build: re-add clang dep --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a66ecd1..faad53e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56.1-slim-buster as builder -ENV builddeps="cmake git" +ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From 2dae6ea636f8d21ee73335f64b519ca48237682d Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:59:49 -0700 Subject: [PATCH 06/34] Add note about Debian dependencies to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e6a0cbb..a10b2ea4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ and the API is subject to change._ ``` This will put a copy of the `ion` executable in `~/.cargo/bin`. - **If this step fails:** You're likely missing one of `ion-c`'s dependencies. Make sure you have `cmake` and `clang` installed. + **If this step fails:** You're likely missing one of `ion-c`'s dependencies. Make sure you have `cmake`, `gcc`, `g++` and `clang` installed. On Debian-based Linux distributions, the only required dependencies are `cmake` and `clang`. 5. Confirm that `~/.cargo/bin` is on your `$PATH`. `rustup` will probably take care of this for you. From 7cae48365f1e527e1bd6a39c9bca8c36f504f4e0 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 7 Nov 2021 22:42:03 -0700 Subject: [PATCH 07/34] Add basic, runnable tests --- Cargo.lock | 264 ++++++++++++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 9 +- tests/cli.rs | 120 +++++++++++++++++++++++ 3 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index ad624907..77fbaea4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.7.15" @@ -21,6 +23,26 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "assert_cmd" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe" +dependencies = [ + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "atty" version = "0.2.14" @@ -91,6 +113,29 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitvec" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", +] + [[package]] name = "byteorder" version = "1.4.2" @@ -119,7 +164,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ - "nom", + "nom 5.1.2", ] [[package]] @@ -204,6 +249,24 @@ dependencies = [ "syn", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "env_logger" version = "0.7.1" @@ -217,6 +280,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "getrandom" version = "0.2.2" @@ -271,20 +340,22 @@ name = "ion-cli" version = "0.1.1" dependencies = [ "anyhow", + "assert_cmd", "clap", "cmake", "colored", "ion-rs", "libc", "memmap", + "rstest", "tempfile", ] [[package]] name = "ion-rs" -version = "0.3.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4041afcc61aa4e57c5b11dc3d0dee9bff91012b524a5f8140511d9ccc5768d46" +checksum = "f9b5511aa03f80ded9dd90d0244770cd7280a8eea1546fa25ea8f3e4dad0a541" dependencies = [ "base64", "bigdecimal", @@ -292,6 +363,9 @@ dependencies = [ "chrono", "delegate", "ion-c-sys", + "nom 6.1.2", + "num-bigint", + "num-traits", "thiserror", ] @@ -304,6 +378,15 @@ dependencies = [ "libc", ] +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -316,6 +399,19 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lexical-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" +dependencies = [ + "arrayvec", + "bitflags 1.2.1", + "cfg-if 1.0.0", + "ryu", + "static_assertions", +] + [[package]] name = "libc" version = "0.2.83" @@ -343,9 +439,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memmap" @@ -367,6 +463,19 @@ dependencies = [ "version_check", ] +[[package]] +name = "nom" +version = "6.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +dependencies = [ + "bitvec", + "funty", + "lexical-core", + "memchr", + "version_check", +] + [[package]] name = "num-bigint" version = "0.3.1" @@ -415,17 +524,53 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "ppv-lite86" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "predicates" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" + +[[package]] +name = "predicates-tree" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] @@ -438,13 +583,19 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" + [[package]] name = "rand" version = "0.8.3" @@ -506,6 +657,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.22" @@ -521,18 +678,70 @@ dependencies = [ "winapi", ] +[[package]] +name = "rstest" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "shlex" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.6.0" @@ -541,15 +750,21 @@ checksum = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" [[package]] name = "syn" -version = "1.0.60" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.2.0" @@ -573,6 +788,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + [[package]] name = "textwrap" version = "0.9.0" @@ -621,6 +842,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-width" version = "0.1.8" @@ -645,6 +872,15 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -690,3 +926,9 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" diff --git a/Cargo.toml b/Cargo.toml index f9135d56..306edbf5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = ["format", "parse", "encode"] anyhow = "1.0" clap = "~2.27.0" colored = "2.0.0" -ion-rs = "0.3.1" +ion-rs = "~0.6.0" libc = "0.2" memmap = "0.7.0" tempfile = "3.2.0" @@ -23,7 +23,12 @@ tempfile = "3.2.0" [build-dependencies] cmake = "0.1.44" +[dev-dependencies] +rstest = "~0.10.0" +assert_cmd = "~1.0.5" +tempfile = "~3.2.0" + [[bin]] name = "ion" -test = false +test = true bench = false diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 00000000..1b8b20c0 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,120 @@ +use anyhow::Result; +use ion_rs::value::owned::OwnedElement; +use ion_rs::value::reader::*; +use rstest::*; +use std::fs::File; +use std::io::{Read, Write}; +use std::time::Duration; +use tempfile::TempDir; +use assert_cmd::Command; + +enum FileMode { + /// Use `STDIN` or `STDOUT` + Default, + /// Use a named file + Named, +} + +struct TestCase> { + /// The text of the ion grammar to test + ion_text: S, + /// The expected Ion + expected_ion: OwnedElement, +} + +impl From<(&'static str, &'static str)> for TestCase<&'static str> { + /// Simple conversion for static `str` slices into a test case + fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { + let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); + Self { + ion_text, + expected_ion + } + } +} + +#[rstest] +#[case::simple(( +r#" +{ + name: "Fido" +} +"#, +r#" +{ + name: "Fido" +} +"# +).into())] +fn run_it>( + #[case] test_case: TestCase, +#[values("", "binary", "text", "pretty")] format_flag: &str, +#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, +#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode +) -> Result<()> { + + let TestCase { + ion_text, + expected_ion + } = test_case; + + let temp_dir = TempDir::new()?; + let input_path = temp_dir.path().join("INPUT.ion"); + let output_path = temp_dir.path().join("OUTPUT.ion"); + + let mut cmd = Command::cargo_bin("ion")?; + cmd.arg("dump").timeout(Duration::new(5, 0)); + if format_flag != "" { + cmd.arg("-f"); + cmd.arg(format_flag); + } + match output_mode { + FileMode::Default => { + // do nothing + }, + FileMode::Named => { + // tell driver to output to a file + cmd.arg("-o"); + cmd.arg(&output_path); + } + }; + + match input_mode { + FileMode::Default => { + // do nothing + cmd.write_stdin(ion_text.as_ref()); + }, + FileMode::Named => { + // dump our test data to input file + let mut input_file = File::create(&input_path)?; + input_file.write(ion_text.as_ref().as_bytes())?; + input_file.flush()?; + + // TODO: test multiple input files + + // make this the input for our driver + cmd.arg(input_path.to_str().unwrap()); + + } + }; + + let assert = cmd.assert(); + + let actual_ion = match output_mode { + FileMode::Default => { + let output = assert.get_output(); + element_reader().read_one(&output.stdout)? + } + FileMode::Named => { + let mut output_file = File::open(output_path)?; + let mut output_buffer = vec![]; + output_file.read_to_end(&mut output_buffer)?; + element_reader().read_one(&output_buffer)? + } + }; + + assert_eq!(expected_ion, actual_ion); + assert.success(); + + Ok(()) +} \ No newline at end of file From 6c5218a5c767c735e47a937c35e6f02331b63fcb Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 21 Nov 2021 22:58:04 -0700 Subject: [PATCH 08/34] Update ion-rs version, ion-c submodule and Dockerfile --- Cargo.lock | 157 --------------------------------------------------- Cargo.toml | 7 +-- Dockerfile | 2 +- ion-c | 2 +- tests/cli.rs | 120 --------------------------------------- 5 files changed, 3 insertions(+), 285 deletions(-) delete mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index 77fbaea4..f56486f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,20 +29,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" -[[package]] -name = "assert_cmd" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe" -dependencies = [ - "bstr", - "doc-comment", - "predicates", - "predicates-core", - "predicates-tree", - "wait-timeout", -] - [[package]] name = "atty" version = "0.2.14" @@ -125,17 +111,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", -] - [[package]] name = "byteorder" version = "1.4.2" @@ -249,24 +224,6 @@ dependencies = [ "syn", ] -[[package]] -name = "difflib" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - [[package]] name = "env_logger" version = "0.7.1" @@ -340,14 +297,12 @@ name = "ion-cli" version = "0.1.1" dependencies = [ "anyhow", - "assert_cmd", "clap", "cmake", "colored", "ion-rs", "libc", "memmap", - "rstest", "tempfile", ] @@ -378,15 +333,6 @@ dependencies = [ "libc", ] -[[package]] -name = "itertools" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" -dependencies = [ - "either", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -524,48 +470,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "ppv-lite86" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" -[[package]] -name = "predicates" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474" -dependencies = [ - "difflib", - "itertools", - "predicates-core", -] - -[[package]] -name = "predicates-core" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" - -[[package]] -name = "predicates-tree" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" -dependencies = [ - "predicates-core", - "termtree", -] - [[package]] name = "proc-macro2" version = "1.0.32" @@ -657,12 +567,6 @@ dependencies = [ "thread_local", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" version = "0.6.22" @@ -678,58 +582,18 @@ dependencies = [ "winapi", ] -[[package]] -name = "rstest" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" -dependencies = [ - "cfg-if 1.0.0", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver", -] - [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "shlex" version = "0.1.1" @@ -788,12 +652,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "termtree" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" - [[package]] name = "textwrap" version = "0.9.0" @@ -842,12 +700,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "unicode-width" version = "0.1.8" @@ -872,15 +724,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -[[package]] -name = "wait-timeout" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" -dependencies = [ - "libc", -] - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 306edbf5..71ef7f60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,12 +23,7 @@ tempfile = "3.2.0" [build-dependencies] cmake = "0.1.44" -[dev-dependencies] -rstest = "~0.10.0" -assert_cmd = "~1.0.5" -tempfile = "~3.2.0" - [[bin]] name = "ion" -test = true +test = false bench = false diff --git a/Dockerfile b/Dockerfile index faad53e6..4e084132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ COPY . . RUN apt-get update -y \ && apt-get install -y ${builddeps} \ && git submodule update --init --recursive -RUN cargo install --path . +RUN cargo install --verbose --path . FROM debian:11.1-slim COPY --from=builder /usr/local/cargo/bin/ion /usr/bin/ion diff --git a/ion-c b/ion-c index a9af6be3..a1a953c7 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit a9af6be3f2ed38d4775257adfa5672c845cac361 +Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 diff --git a/tests/cli.rs b/tests/cli.rs deleted file mode 100644 index 1b8b20c0..00000000 --- a/tests/cli.rs +++ /dev/null @@ -1,120 +0,0 @@ -use anyhow::Result; -use ion_rs::value::owned::OwnedElement; -use ion_rs::value::reader::*; -use rstest::*; -use std::fs::File; -use std::io::{Read, Write}; -use std::time::Duration; -use tempfile::TempDir; -use assert_cmd::Command; - -enum FileMode { - /// Use `STDIN` or `STDOUT` - Default, - /// Use a named file - Named, -} - -struct TestCase> { - /// The text of the ion grammar to test - ion_text: S, - /// The expected Ion - expected_ion: OwnedElement, -} - -impl From<(&'static str, &'static str)> for TestCase<&'static str> { - /// Simple conversion for static `str` slices into a test case - fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { - let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); - Self { - ion_text, - expected_ion - } - } -} - -#[rstest] -#[case::simple(( -r#" -{ - name: "Fido" -} -"#, -r#" -{ - name: "Fido" -} -"# -).into())] -fn run_it>( - #[case] test_case: TestCase, -#[values("", "binary", "text", "pretty")] format_flag: &str, -#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, -#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode -) -> Result<()> { - - let TestCase { - ion_text, - expected_ion - } = test_case; - - let temp_dir = TempDir::new()?; - let input_path = temp_dir.path().join("INPUT.ion"); - let output_path = temp_dir.path().join("OUTPUT.ion"); - - let mut cmd = Command::cargo_bin("ion")?; - cmd.arg("dump").timeout(Duration::new(5, 0)); - if format_flag != "" { - cmd.arg("-f"); - cmd.arg(format_flag); - } - match output_mode { - FileMode::Default => { - // do nothing - }, - FileMode::Named => { - // tell driver to output to a file - cmd.arg("-o"); - cmd.arg(&output_path); - } - }; - - match input_mode { - FileMode::Default => { - // do nothing - cmd.write_stdin(ion_text.as_ref()); - }, - FileMode::Named => { - // dump our test data to input file - let mut input_file = File::create(&input_path)?; - input_file.write(ion_text.as_ref().as_bytes())?; - input_file.flush()?; - - // TODO: test multiple input files - - // make this the input for our driver - cmd.arg(input_path.to_str().unwrap()); - - } - }; - - let assert = cmd.assert(); - - let actual_ion = match output_mode { - FileMode::Default => { - let output = assert.get_output(); - element_reader().read_one(&output.stdout)? - } - FileMode::Named => { - let mut output_file = File::open(output_path)?; - let mut output_buffer = vec![]; - output_file.read_to_end(&mut output_buffer)?; - element_reader().read_one(&output_buffer)? - } - }; - - assert_eq!(expected_ion, actual_ion); - assert.success(); - - Ok(()) -} \ No newline at end of file From 39f03c1338704c877bd0ddabea63d9a04cc1debe Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 7 Nov 2021 22:42:03 -0700 Subject: [PATCH 09/34] Add basic, runnable tests --- Cargo.lock | 78 +++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++- tests/cli.rs | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index f56486f9..93c4b456 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,6 +224,24 @@ dependencies = [ "syn", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "env_logger" version = "0.7.1" @@ -297,12 +315,14 @@ name = "ion-cli" version = "0.1.1" dependencies = [ "anyhow", + "assert_cmd", "clap", "cmake", "colored", "ion-rs", "libc", "memmap", + "rstest", "tempfile", ] @@ -333,6 +353,15 @@ dependencies = [ "libc", ] +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -470,6 +499,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -567,6 +605,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.22" @@ -582,6 +626,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "rstest" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -652,6 +709,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + [[package]] name = "textwrap" version = "0.9.0" @@ -700,6 +763,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-width" version = "0.1.8" @@ -724,6 +793,15 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 3ea4fcf6..68f311a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,12 @@ ion-schema = "0.1.0" [build-dependencies] cmake = "0.1.44" +[dev-dependencies] +rstest = "~0.10.0" +assert_cmd = "~1.0.5" +tempfile = "~3.2.0" + [[bin]] name = "ion" -test = false +test = true bench = false diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 00000000..1b8b20c0 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,120 @@ +use anyhow::Result; +use ion_rs::value::owned::OwnedElement; +use ion_rs::value::reader::*; +use rstest::*; +use std::fs::File; +use std::io::{Read, Write}; +use std::time::Duration; +use tempfile::TempDir; +use assert_cmd::Command; + +enum FileMode { + /// Use `STDIN` or `STDOUT` + Default, + /// Use a named file + Named, +} + +struct TestCase> { + /// The text of the ion grammar to test + ion_text: S, + /// The expected Ion + expected_ion: OwnedElement, +} + +impl From<(&'static str, &'static str)> for TestCase<&'static str> { + /// Simple conversion for static `str` slices into a test case + fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { + let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); + Self { + ion_text, + expected_ion + } + } +} + +#[rstest] +#[case::simple(( +r#" +{ + name: "Fido" +} +"#, +r#" +{ + name: "Fido" +} +"# +).into())] +fn run_it>( + #[case] test_case: TestCase, +#[values("", "binary", "text", "pretty")] format_flag: &str, +#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, +#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode +) -> Result<()> { + + let TestCase { + ion_text, + expected_ion + } = test_case; + + let temp_dir = TempDir::new()?; + let input_path = temp_dir.path().join("INPUT.ion"); + let output_path = temp_dir.path().join("OUTPUT.ion"); + + let mut cmd = Command::cargo_bin("ion")?; + cmd.arg("dump").timeout(Duration::new(5, 0)); + if format_flag != "" { + cmd.arg("-f"); + cmd.arg(format_flag); + } + match output_mode { + FileMode::Default => { + // do nothing + }, + FileMode::Named => { + // tell driver to output to a file + cmd.arg("-o"); + cmd.arg(&output_path); + } + }; + + match input_mode { + FileMode::Default => { + // do nothing + cmd.write_stdin(ion_text.as_ref()); + }, + FileMode::Named => { + // dump our test data to input file + let mut input_file = File::create(&input_path)?; + input_file.write(ion_text.as_ref().as_bytes())?; + input_file.flush()?; + + // TODO: test multiple input files + + // make this the input for our driver + cmd.arg(input_path.to_str().unwrap()); + + } + }; + + let assert = cmd.assert(); + + let actual_ion = match output_mode { + FileMode::Default => { + let output = assert.get_output(); + element_reader().read_one(&output.stdout)? + } + FileMode::Named => { + let mut output_file = File::open(output_path)?; + let mut output_buffer = vec![]; + output_file.read_to_end(&mut output_buffer)?; + element_reader().read_one(&output_buffer)? + } + }; + + assert_eq!(expected_ion, actual_ion); + assert.success(); + + Ok(()) +} \ No newline at end of file From 0e36543908b5750fa3d0dbcd1e2b0fde771470c4 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 19 Dec 2021 01:51:32 -0700 Subject: [PATCH 10/34] Add basic workflows for coverage and build --- .github/codecov.yml | 10 +++++++ .github/workflows/build.yml | 52 ++++++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 45 +++++++++++++++++++++++++++++ tests/cli.rs | 34 +++++++++++++++++++--- 4 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 .github/codecov.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/coverage.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..09a96dde --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: + default: + target: 50% + threshold: 5% + patch: + default: + target: 55% + threshold: 5% diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..96f2bfbe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: CI Build + +on: [push, pull_request] + +jobs: + build: + name: Build and Test + runs-on: ${{ matrix.os }} + # We want to run on external PRs, but not on internal ones as push automatically builds + # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-rust' + strategy: + matrix: + # TODO: add windows after fixing build issues + os: [ubuntu-latest, macos-latest] + + steps: + # TODO: fix Windows build + # - name: Remove MSys64 MingW64 Binaries + # if: runner.os == 'Windows' + # # remove this because there is a bad libclang.dll that confuses bindgen + # run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse + # - name: Install Dependencies + # if: runner.os == 'Windows' + # run: choco install llvm -y + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Cargo Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --verbose --workspace + - name: Cargo Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose --workspace + + # TODO: fix rustfmt issues + # - name: Rustfmt Check + # uses: actions-rs/cargo@v1 + # with: + # command: fmt + # args: --verbose -- --check diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..1df29076 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,45 @@ +name: Code Coverage + # original source: https://github.com/amzn/ion-rust/blob/main/.github/workflows/coverage.yml +on: [push, pull_request] + +jobs: + build: + name: Build and Test + runs-on: ${{ matrix.os }} + # We want to run on external PRs, but not on internal ones as push automatically builds + # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-cli' + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + # nightly can be very volatile--pin this to a version we know works well... + toolchain: nightly-2021-08-30 + override: true + - name: Cargo Test + # uses: actions-rs/cargo@v1 + env: + CARGO_INCREMENTAL: '0' + # https://github.com/marketplace/actions/rust-grcov + # For some reason the panic=abort modes don't work for build script... + #RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + #RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' + run: | + cargo test --workspace --all-features --no-fail-fast --verbose -- --test-threads=1 + - id: coverage + name: Code Coverage + uses: actions-rs/grcov@v0.1 + - name: Codecov Upload + uses: codecov/codecov-action@v1 + with: + files: ${{ steps.coverage.outputs.report }} diff --git a/tests/cli.rs b/tests/cli.rs index 1b8b20c0..d71c2e7c 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -16,7 +16,7 @@ enum FileMode { } struct TestCase> { - /// The text of the ion grammar to test + /// The text of the ion payload to test ion_text: S, /// The expected Ion expected_ion: OwnedElement, @@ -37,12 +37,38 @@ impl From<(&'static str, &'static str)> for TestCase<&'static str> { #[case::simple(( r#" { - name: "Fido" + name: "Fido", + + age: years::4, + + birthday: 2012-03-01T, + + toys: [ + ball, + rope, + ], + + weight: pounds::41.2, + + buzz: {{VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE=}}, } "#, r#" { - name: "Fido" + name: "Fido", + + age: years::4, + + birthday: 2012-03-01T, + + toys: [ + ball, + rope, + ], + + weight: pounds::41.2, + + buzz: {{VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE=}}, } "# ).into())] @@ -117,4 +143,4 @@ fn run_it>( assert.success(); Ok(()) -} \ No newline at end of file +} From 290c4f956295bf6dd3c2736ff49c5fe0995059b3 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 27 Dec 2021 11:40:16 -0700 Subject: [PATCH 11/34] rebase branch and add new Cargo.lock, ion-c changes --- Cargo.lock | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++- ion-c | 2 +- 2 files changed, 121 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93c4b456..151cd242 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,6 +29,26 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "assert_cmd" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe" +dependencies = [ + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "atty" version = "0.2.14" @@ -111,6 +131,17 @@ dependencies = [ "wyz", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", +] + [[package]] name = "byteorder" version = "1.4.2" @@ -319,7 +350,8 @@ dependencies = [ "clap", "cmake", "colored", - "ion-rs", + "ion-rs 0.6.0", + "ion-schema", "libc", "memmap", "rstest", @@ -344,6 +376,38 @@ dependencies = [ "thiserror", ] +[[package]] +name = "ion-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf75af80121752ccbbab9db0366ba35ee48ecc6167cc41fce8a634601138f8c" +dependencies = [ + "arrayvec 0.7.2", + "base64", + "bigdecimal", + "bytes", + "chrono", + "delegate", + "ion-c-sys", + "nom 6.1.2", + "num-bigint", + "num-traits", + "thiserror", +] + +[[package]] +name = "ion-schema" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e16fcad39203a34e529cfb7da57df3e04c37dfc9bdb831399ed3bcd1bb865" +dependencies = [ + "chrono", + "ion-rs 0.7.0", + "num-bigint", + "num-traits", + "thiserror", +] + [[package]] name = "iovec" version = "0.1.4" @@ -380,7 +444,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ - "arrayvec", + "arrayvec 0.5.2", "bitflags 1.2.1", "cfg-if 1.0.0", "ryu", @@ -514,6 +578,33 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "predicates" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" + +[[package]] +name = "predicates-tree" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.32" @@ -645,12 +736,39 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "shlex" version = "0.1.1" diff --git a/ion-c b/ion-c index a1a953c7..a9af6be3 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 +Subproject commit a9af6be3f2ed38d4775257adfa5672c845cac361 From 784c43e5516db8b1c91db09b746800c3e8228662 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 27 Dec 2021 11:43:19 -0700 Subject: [PATCH 12/34] pin to specific cargo release --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96f2bfbe..a28cad49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,8 @@ jobs: - name: Rust Toolchain uses: actions-rs/toolchain@v1 with: - profile: minimal - toolchain: stable + # nightly can be very volatile--pin this to a version we know works well... + toolchain: nightly-2021-08-30 override: true - name: Cargo Build uses: actions-rs/cargo@v1 @@ -42,7 +42,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --verbose --workspace + args: --verbose --workspace -- --test-threads=1 # TODO: fix rustfmt issues # - name: Rustfmt Check From 1a53227905d339def9dbe3150778301f06121d0f Mon Sep 17 00:00:00 2001 From: cam Date: Thu, 10 Feb 2022 10:18:56 -0800 Subject: [PATCH 13/34] Make bin match cargo name --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 68f311a4..cdafb14a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,6 @@ assert_cmd = "~1.0.5" tempfile = "~3.2.0" [[bin]] -name = "ion" +name = "ion-cli" test = true bench = false From 5dfab4d83496b48e672de848649969caa79f6ee9 Mon Sep 17 00:00:00 2001 From: cam Date: Thu, 10 Feb 2022 10:24:13 -0800 Subject: [PATCH 14/34] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cdafb14a..68f311a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,6 @@ assert_cmd = "~1.0.5" tempfile = "~3.2.0" [[bin]] -name = "ion-cli" +name = "ion" test = true bench = false From 3f48b3703b48e8349733b691c2db68ea440bda64 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Fri, 22 Oct 2021 05:04:57 -0700 Subject: [PATCH 15/34] Add Dockerfile and Docker usage instructions * Added Dockerfile to build minimal, multi-stage image * Updated README with build instructions Recording of local build/test: https://asciinema.org/a/Ql7Xc5fgxxvkFrjjcuMbR0npY Currently builds image size 85.8MB from local build on macOS ``` docker images REPOSITORY TAG IMAGE ID CREATED SIZE ion-cli 0.1.1 e81a9d863b95 49 minutes ago 85.8MB ``` --- Dockerfile | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e084132..3017ee6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM rust:1.56.1-slim-buster as builder -ENV builddeps="cmake git clang" +FROM rust:1.56-slim as builder +ENV builddeps="cmake git gcc g++ clang" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ && apt-get install -y ${builddeps} \ && git submodule update --init --recursive -RUN cargo install --verbose --path . +RUN cargo install --path . FROM debian:11.1-slim COPY --from=builder /usr/local/cargo/bin/ion /usr/bin/ion diff --git a/README.md b/README.md index a10b2ea4..59cbec71 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,15 @@ and the API is subject to change._ ### Docker Instructions -1. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) -2. Clone the repository (recursive clone not necessary) +1. Clone the repository (recursive clone not necessary) ``` git clone https://github.com/amzn/ion-cli.git ``` -3. Step into the newly created directory +2. Step into the newly created directory ``` cd ion-cli ``` +3. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) 4. Build and run the image ``` # build the image From 6e2a4459fb6c5a1b41223d89985b0cc35eba509c Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Fri, 22 Oct 2021 05:27:29 -0700 Subject: [PATCH 16/34] Remove unnecessary gcc, g++ deps in builder img --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3017ee6e..0cb18121 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56-slim as builder -ENV builddeps="cmake git gcc g++ clang" +ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From d853d6e0ec2ed95c0fc7c33770011e5c6a49525a Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:38:53 -0700 Subject: [PATCH 17/34] Add build workflow, cleanup README --- Dockerfile | 2 +- README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0cb18121..faad53e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.56-slim as builder +FROM rust:1.56.1-slim-buster as builder ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . diff --git a/README.md b/README.md index 59cbec71..a10b2ea4 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,15 @@ and the API is subject to change._ ### Docker Instructions -1. Clone the repository (recursive clone not necessary) +1. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) +2. Clone the repository (recursive clone not necessary) ``` git clone https://github.com/amzn/ion-cli.git ``` -2. Step into the newly created directory +3. Step into the newly created directory ``` cd ion-cli ``` -3. Install Docker (see OS specific instructions on the [Docker website](https://docs.docker.com/get-docker/)) 4. Build and run the image ``` # build the image From 20fc2e5e70936156b7a2d52ec0d0825df455290f Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:48:52 -0700 Subject: [PATCH 18/34] Test: intentionally break build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index faad53e6..1a66ecd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56.1-slim-buster as builder -ENV builddeps="cmake git clang" +ENV builddeps="cmake git" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From 51ec03938b0e347a65677805367aee9ee70e3034 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 1 Nov 2021 21:52:37 -0700 Subject: [PATCH 19/34] Fix build: re-add clang dep --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a66ecd1..faad53e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.56.1-slim-buster as builder -ENV builddeps="cmake git" +ENV builddeps="cmake git clang" WORKDIR /usr/src/ion-cli COPY . . RUN apt-get update -y \ From d4b7fa9ac0c6d7d4ea93dfa6a7df594218d72f07 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 7 Nov 2021 22:42:03 -0700 Subject: [PATCH 20/34] Add basic, runnable tests --- Cargo.lock | 78 +++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++- tests/cli.rs | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index b92f1469..d71c6281 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,6 +230,24 @@ dependencies = [ "syn", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "env_logger" version = "0.7.1" @@ -303,6 +321,7 @@ name = "ion-cli" version = "0.2.0" dependencies = [ "anyhow", + "assert_cmd", "clap", "cmake", "colored", @@ -310,6 +329,7 @@ dependencies = [ "ion-schema", "libc", "memmap", + "rstest", "tempfile", ] @@ -373,6 +393,15 @@ dependencies = [ "libc", ] +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -510,6 +539,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -607,6 +645,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.22" @@ -622,6 +666,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "rstest" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -692,6 +749,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + [[package]] name = "textwrap" version = "0.9.0" @@ -740,6 +803,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-width" version = "0.1.8" @@ -764,6 +833,15 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index ce75b3fd..9b8dbadc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,12 @@ ion-schema = "0.1.0" [build-dependencies] cmake = "0.1.44" +[dev-dependencies] +rstest = "~0.10.0" +assert_cmd = "~1.0.5" +tempfile = "~3.2.0" + [[bin]] name = "ion" -test = false +test = true bench = false diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 00000000..1b8b20c0 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,120 @@ +use anyhow::Result; +use ion_rs::value::owned::OwnedElement; +use ion_rs::value::reader::*; +use rstest::*; +use std::fs::File; +use std::io::{Read, Write}; +use std::time::Duration; +use tempfile::TempDir; +use assert_cmd::Command; + +enum FileMode { + /// Use `STDIN` or `STDOUT` + Default, + /// Use a named file + Named, +} + +struct TestCase> { + /// The text of the ion grammar to test + ion_text: S, + /// The expected Ion + expected_ion: OwnedElement, +} + +impl From<(&'static str, &'static str)> for TestCase<&'static str> { + /// Simple conversion for static `str` slices into a test case + fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { + let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); + Self { + ion_text, + expected_ion + } + } +} + +#[rstest] +#[case::simple(( +r#" +{ + name: "Fido" +} +"#, +r#" +{ + name: "Fido" +} +"# +).into())] +fn run_it>( + #[case] test_case: TestCase, +#[values("", "binary", "text", "pretty")] format_flag: &str, +#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, +#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode +) -> Result<()> { + + let TestCase { + ion_text, + expected_ion + } = test_case; + + let temp_dir = TempDir::new()?; + let input_path = temp_dir.path().join("INPUT.ion"); + let output_path = temp_dir.path().join("OUTPUT.ion"); + + let mut cmd = Command::cargo_bin("ion")?; + cmd.arg("dump").timeout(Duration::new(5, 0)); + if format_flag != "" { + cmd.arg("-f"); + cmd.arg(format_flag); + } + match output_mode { + FileMode::Default => { + // do nothing + }, + FileMode::Named => { + // tell driver to output to a file + cmd.arg("-o"); + cmd.arg(&output_path); + } + }; + + match input_mode { + FileMode::Default => { + // do nothing + cmd.write_stdin(ion_text.as_ref()); + }, + FileMode::Named => { + // dump our test data to input file + let mut input_file = File::create(&input_path)?; + input_file.write(ion_text.as_ref().as_bytes())?; + input_file.flush()?; + + // TODO: test multiple input files + + // make this the input for our driver + cmd.arg(input_path.to_str().unwrap()); + + } + }; + + let assert = cmd.assert(); + + let actual_ion = match output_mode { + FileMode::Default => { + let output = assert.get_output(); + element_reader().read_one(&output.stdout)? + } + FileMode::Named => { + let mut output_file = File::open(output_path)?; + let mut output_buffer = vec![]; + output_file.read_to_end(&mut output_buffer)?; + element_reader().read_one(&output_buffer)? + } + }; + + assert_eq!(expected_ion, actual_ion); + assert.success(); + + Ok(()) +} \ No newline at end of file From 37ef0144ac8bd0ebd0558cc356067b0febc7cc15 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 21 Nov 2021 22:58:04 -0700 Subject: [PATCH 21/34] Update ion-rs version, ion-c submodule and Dockerfile --- Cargo.lock | 78 --------------------------------- Cargo.toml | 7 +-- Dockerfile | 2 +- tests/cli.rs | 120 --------------------------------------------------- 4 files changed, 2 insertions(+), 205 deletions(-) delete mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index d71c6281..b92f1469 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,24 +230,6 @@ dependencies = [ "syn", ] -[[package]] -name = "difflib" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - [[package]] name = "env_logger" version = "0.7.1" @@ -321,7 +303,6 @@ name = "ion-cli" version = "0.2.0" dependencies = [ "anyhow", - "assert_cmd", "clap", "cmake", "colored", @@ -329,7 +310,6 @@ dependencies = [ "ion-schema", "libc", "memmap", - "rstest", "tempfile", ] @@ -393,15 +373,6 @@ dependencies = [ "libc", ] -[[package]] -name = "itertools" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" -dependencies = [ - "either", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -539,15 +510,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "ppv-lite86" version = "0.2.10" @@ -645,12 +607,6 @@ dependencies = [ "thread_local", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" version = "0.6.22" @@ -666,19 +622,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rstest" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" -dependencies = [ - "cfg-if 1.0.0", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - [[package]] name = "rustc-hash" version = "1.1.0" @@ -749,12 +692,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "termtree" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" - [[package]] name = "textwrap" version = "0.9.0" @@ -803,12 +740,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "unicode-width" version = "0.1.8" @@ -833,15 +764,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -[[package]] -name = "wait-timeout" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" -dependencies = [ - "libc", -] - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 9b8dbadc..ce75b3fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,12 +24,7 @@ ion-schema = "0.1.0" [build-dependencies] cmake = "0.1.44" -[dev-dependencies] -rstest = "~0.10.0" -assert_cmd = "~1.0.5" -tempfile = "~3.2.0" - [[bin]] name = "ion" -test = true +test = false bench = false diff --git a/Dockerfile b/Dockerfile index faad53e6..4e084132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ COPY . . RUN apt-get update -y \ && apt-get install -y ${builddeps} \ && git submodule update --init --recursive -RUN cargo install --path . +RUN cargo install --verbose --path . FROM debian:11.1-slim COPY --from=builder /usr/local/cargo/bin/ion /usr/bin/ion diff --git a/tests/cli.rs b/tests/cli.rs deleted file mode 100644 index 1b8b20c0..00000000 --- a/tests/cli.rs +++ /dev/null @@ -1,120 +0,0 @@ -use anyhow::Result; -use ion_rs::value::owned::OwnedElement; -use ion_rs::value::reader::*; -use rstest::*; -use std::fs::File; -use std::io::{Read, Write}; -use std::time::Duration; -use tempfile::TempDir; -use assert_cmd::Command; - -enum FileMode { - /// Use `STDIN` or `STDOUT` - Default, - /// Use a named file - Named, -} - -struct TestCase> { - /// The text of the ion grammar to test - ion_text: S, - /// The expected Ion - expected_ion: OwnedElement, -} - -impl From<(&'static str, &'static str)> for TestCase<&'static str> { - /// Simple conversion for static `str` slices into a test case - fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { - let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); - Self { - ion_text, - expected_ion - } - } -} - -#[rstest] -#[case::simple(( -r#" -{ - name: "Fido" -} -"#, -r#" -{ - name: "Fido" -} -"# -).into())] -fn run_it>( - #[case] test_case: TestCase, -#[values("", "binary", "text", "pretty")] format_flag: &str, -#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, -#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode -) -> Result<()> { - - let TestCase { - ion_text, - expected_ion - } = test_case; - - let temp_dir = TempDir::new()?; - let input_path = temp_dir.path().join("INPUT.ion"); - let output_path = temp_dir.path().join("OUTPUT.ion"); - - let mut cmd = Command::cargo_bin("ion")?; - cmd.arg("dump").timeout(Duration::new(5, 0)); - if format_flag != "" { - cmd.arg("-f"); - cmd.arg(format_flag); - } - match output_mode { - FileMode::Default => { - // do nothing - }, - FileMode::Named => { - // tell driver to output to a file - cmd.arg("-o"); - cmd.arg(&output_path); - } - }; - - match input_mode { - FileMode::Default => { - // do nothing - cmd.write_stdin(ion_text.as_ref()); - }, - FileMode::Named => { - // dump our test data to input file - let mut input_file = File::create(&input_path)?; - input_file.write(ion_text.as_ref().as_bytes())?; - input_file.flush()?; - - // TODO: test multiple input files - - // make this the input for our driver - cmd.arg(input_path.to_str().unwrap()); - - } - }; - - let assert = cmd.assert(); - - let actual_ion = match output_mode { - FileMode::Default => { - let output = assert.get_output(); - element_reader().read_one(&output.stdout)? - } - FileMode::Named => { - let mut output_file = File::open(output_path)?; - let mut output_buffer = vec![]; - output_file.read_to_end(&mut output_buffer)?; - element_reader().read_one(&output_buffer)? - } - }; - - assert_eq!(expected_ion, actual_ion); - assert.success(); - - Ok(()) -} \ No newline at end of file From 1583eb9c4867b8f41edaa4fc5fd11e2d9297e114 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 7 Nov 2021 22:42:03 -0700 Subject: [PATCH 22/34] Add basic, runnable tests --- Cargo.lock | 78 +++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++- tests/cli.rs | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index b92f1469..d71c6281 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,6 +230,24 @@ dependencies = [ "syn", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "env_logger" version = "0.7.1" @@ -303,6 +321,7 @@ name = "ion-cli" version = "0.2.0" dependencies = [ "anyhow", + "assert_cmd", "clap", "cmake", "colored", @@ -310,6 +329,7 @@ dependencies = [ "ion-schema", "libc", "memmap", + "rstest", "tempfile", ] @@ -373,6 +393,15 @@ dependencies = [ "libc", ] +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -510,6 +539,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -607,6 +645,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.22" @@ -622,6 +666,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "rstest" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "041bb0202c14f6a158bbbf086afb03d0c6e975c2dec7d4912f8061ed44f290af" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -692,6 +749,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + [[package]] name = "textwrap" version = "0.9.0" @@ -740,6 +803,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-width" version = "0.1.8" @@ -764,6 +833,15 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index ce75b3fd..9b8dbadc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,12 @@ ion-schema = "0.1.0" [build-dependencies] cmake = "0.1.44" +[dev-dependencies] +rstest = "~0.10.0" +assert_cmd = "~1.0.5" +tempfile = "~3.2.0" + [[bin]] name = "ion" -test = false +test = true bench = false diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 00000000..1b8b20c0 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,120 @@ +use anyhow::Result; +use ion_rs::value::owned::OwnedElement; +use ion_rs::value::reader::*; +use rstest::*; +use std::fs::File; +use std::io::{Read, Write}; +use std::time::Duration; +use tempfile::TempDir; +use assert_cmd::Command; + +enum FileMode { + /// Use `STDIN` or `STDOUT` + Default, + /// Use a named file + Named, +} + +struct TestCase> { + /// The text of the ion grammar to test + ion_text: S, + /// The expected Ion + expected_ion: OwnedElement, +} + +impl From<(&'static str, &'static str)> for TestCase<&'static str> { + /// Simple conversion for static `str` slices into a test case + fn from((ion_text, expected_ion): (&'static str, &'static str)) -> Self { + let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); + Self { + ion_text, + expected_ion + } + } +} + +#[rstest] +#[case::simple(( +r#" +{ + name: "Fido" +} +"#, +r#" +{ + name: "Fido" +} +"# +).into())] +fn run_it>( + #[case] test_case: TestCase, +#[values("", "binary", "text", "pretty")] format_flag: &str, +#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, +#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode +) -> Result<()> { + + let TestCase { + ion_text, + expected_ion + } = test_case; + + let temp_dir = TempDir::new()?; + let input_path = temp_dir.path().join("INPUT.ion"); + let output_path = temp_dir.path().join("OUTPUT.ion"); + + let mut cmd = Command::cargo_bin("ion")?; + cmd.arg("dump").timeout(Duration::new(5, 0)); + if format_flag != "" { + cmd.arg("-f"); + cmd.arg(format_flag); + } + match output_mode { + FileMode::Default => { + // do nothing + }, + FileMode::Named => { + // tell driver to output to a file + cmd.arg("-o"); + cmd.arg(&output_path); + } + }; + + match input_mode { + FileMode::Default => { + // do nothing + cmd.write_stdin(ion_text.as_ref()); + }, + FileMode::Named => { + // dump our test data to input file + let mut input_file = File::create(&input_path)?; + input_file.write(ion_text.as_ref().as_bytes())?; + input_file.flush()?; + + // TODO: test multiple input files + + // make this the input for our driver + cmd.arg(input_path.to_str().unwrap()); + + } + }; + + let assert = cmd.assert(); + + let actual_ion = match output_mode { + FileMode::Default => { + let output = assert.get_output(); + element_reader().read_one(&output.stdout)? + } + FileMode::Named => { + let mut output_file = File::open(output_path)?; + let mut output_buffer = vec![]; + output_file.read_to_end(&mut output_buffer)?; + element_reader().read_one(&output_buffer)? + } + }; + + assert_eq!(expected_ion, actual_ion); + assert.success(); + + Ok(()) +} \ No newline at end of file From b7b4fdb4367a15a5319817a4331dff2e545f2d56 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 19 Dec 2021 01:51:32 -0700 Subject: [PATCH 23/34] Add basic workflows for coverage and build --- .github/codecov.yml | 10 +++++++ .github/workflows/build.yml | 52 ++++++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 45 +++++++++++++++++++++++++++++ tests/cli.rs | 34 +++++++++++++++++++--- 4 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 .github/codecov.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/coverage.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..09a96dde --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: + default: + target: 50% + threshold: 5% + patch: + default: + target: 55% + threshold: 5% diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..96f2bfbe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: CI Build + +on: [push, pull_request] + +jobs: + build: + name: Build and Test + runs-on: ${{ matrix.os }} + # We want to run on external PRs, but not on internal ones as push automatically builds + # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-rust' + strategy: + matrix: + # TODO: add windows after fixing build issues + os: [ubuntu-latest, macos-latest] + + steps: + # TODO: fix Windows build + # - name: Remove MSys64 MingW64 Binaries + # if: runner.os == 'Windows' + # # remove this because there is a bad libclang.dll that confuses bindgen + # run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse + # - name: Install Dependencies + # if: runner.os == 'Windows' + # run: choco install llvm -y + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Cargo Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --verbose --workspace + - name: Cargo Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose --workspace + + # TODO: fix rustfmt issues + # - name: Rustfmt Check + # uses: actions-rs/cargo@v1 + # with: + # command: fmt + # args: --verbose -- --check diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..1df29076 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,45 @@ +name: Code Coverage + # original source: https://github.com/amzn/ion-rust/blob/main/.github/workflows/coverage.yml +on: [push, pull_request] + +jobs: + build: + name: Build and Test + runs-on: ${{ matrix.os }} + # We want to run on external PRs, but not on internal ones as push automatically builds + # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-cli' + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + # nightly can be very volatile--pin this to a version we know works well... + toolchain: nightly-2021-08-30 + override: true + - name: Cargo Test + # uses: actions-rs/cargo@v1 + env: + CARGO_INCREMENTAL: '0' + # https://github.com/marketplace/actions/rust-grcov + # For some reason the panic=abort modes don't work for build script... + #RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + #RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' + run: | + cargo test --workspace --all-features --no-fail-fast --verbose -- --test-threads=1 + - id: coverage + name: Code Coverage + uses: actions-rs/grcov@v0.1 + - name: Codecov Upload + uses: codecov/codecov-action@v1 + with: + files: ${{ steps.coverage.outputs.report }} diff --git a/tests/cli.rs b/tests/cli.rs index 1b8b20c0..d71c2e7c 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -16,7 +16,7 @@ enum FileMode { } struct TestCase> { - /// The text of the ion grammar to test + /// The text of the ion payload to test ion_text: S, /// The expected Ion expected_ion: OwnedElement, @@ -37,12 +37,38 @@ impl From<(&'static str, &'static str)> for TestCase<&'static str> { #[case::simple(( r#" { - name: "Fido" + name: "Fido", + + age: years::4, + + birthday: 2012-03-01T, + + toys: [ + ball, + rope, + ], + + weight: pounds::41.2, + + buzz: {{VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE=}}, } "#, r#" { - name: "Fido" + name: "Fido", + + age: years::4, + + birthday: 2012-03-01T, + + toys: [ + ball, + rope, + ], + + weight: pounds::41.2, + + buzz: {{VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE=}}, } "# ).into())] @@ -117,4 +143,4 @@ fn run_it>( assert.success(); Ok(()) -} \ No newline at end of file +} From 33faba8784e6361f99e54db3485b5721f8e54260 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 27 Dec 2021 11:40:16 -0700 Subject: [PATCH 24/34] rebase branch and add new Cargo.lock, ion-c changes --- Cargo.lock | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ion-c | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d71c6281..3fd5fb53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,6 +117,17 @@ dependencies = [ "wyz", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", +] + [[package]] name = "byteorder" version = "1.4.2" @@ -554,6 +565,33 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "predicates" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" + +[[package]] +name = "predicates-tree" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.32" @@ -685,12 +723,39 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "shlex" version = "0.1.1" diff --git a/ion-c b/ion-c index a1a953c7..a9af6be3 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 +Subproject commit a9af6be3f2ed38d4775257adfa5672c845cac361 From 0cd765dbf223be208ebc786b205bed489b150669 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Mon, 27 Dec 2021 11:43:19 -0700 Subject: [PATCH 25/34] pin to specific cargo release --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96f2bfbe..a28cad49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,8 @@ jobs: - name: Rust Toolchain uses: actions-rs/toolchain@v1 with: - profile: minimal - toolchain: stable + # nightly can be very volatile--pin this to a version we know works well... + toolchain: nightly-2021-08-30 override: true - name: Cargo Build uses: actions-rs/cargo@v1 @@ -42,7 +42,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --verbose --workspace + args: --verbose --workspace -- --test-threads=1 # TODO: fix rustfmt issues # - name: Rustfmt Check From 12a3aa5c20cbddfb3bdf75dc643eebe44c6d5392 Mon Sep 17 00:00:00 2001 From: cam Date: Thu, 10 Feb 2022 10:18:56 -0800 Subject: [PATCH 26/34] Make bin match cargo name --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9b8dbadc..7187d5d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,6 @@ assert_cmd = "~1.0.5" tempfile = "~3.2.0" [[bin]] -name = "ion" +name = "ion-cli" test = true bench = false From 1f20d499b2ba77cbb025a0cd86d99e6c6baeb371 Mon Sep 17 00:00:00 2001 From: cam Date: Thu, 10 Feb 2022 10:24:13 -0800 Subject: [PATCH 27/34] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7187d5d2..9b8dbadc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,6 @@ assert_cmd = "~1.0.5" tempfile = "~3.2.0" [[bin]] -name = "ion-cli" +name = "ion" test = true bench = false From 79806668875036cdf042619803ef2ccf62eff111 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Sun, 20 Feb 2022 15:50:49 -0700 Subject: [PATCH 28/34] * use 2022 pinned version and fix edition 2021 errors * update to latest ion-c commit * add rust fmt and use stable toolchain for build --- .github/codecov.yml | 10 --------- .github/workflows/build.yml | 26 ++++++++---------------- .github/workflows/coverage.yml | 9 ++++---- build.rs | 20 ++++++++++++++---- ion-c | 2 +- src/bin/ion/commands/beta/mod.rs | 11 ++++------ src/bin/ion/commands/beta/schema/load.rs | 5 ++--- src/bin/ion/commands/beta/schema/mod.rs | 12 +++++------ src/bin/ion/commands/dump.rs | 2 +- src/bin/ion/commands/mod.rs | 5 +---- src/bin/ion/main.rs | 4 ++-- tests/cli.rs | 18 ++++++++-------- 12 files changed, 53 insertions(+), 71 deletions(-) delete mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml deleted file mode 100644 index 09a96dde..00000000 --- a/.github/codecov.yml +++ /dev/null @@ -1,10 +0,0 @@ -coverage: - status: - project: - default: - target: 50% - threshold: 5% - patch: - default: - target: 55% - threshold: 5% diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a28cad49..ee5efcb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,21 +8,13 @@ jobs: runs-on: ${{ matrix.os }} # We want to run on external PRs, but not on internal ones as push automatically builds # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-rust' + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-cli' strategy: matrix: # TODO: add windows after fixing build issues os: [ubuntu-latest, macos-latest] steps: - # TODO: fix Windows build - # - name: Remove MSys64 MingW64 Binaries - # if: runner.os == 'Windows' - # # remove this because there is a bad libclang.dll that confuses bindgen - # run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse - # - name: Install Dependencies - # if: runner.os == 'Windows' - # run: choco install llvm -y - name: Git Checkout uses: actions/checkout@v2 with: @@ -30,8 +22,8 @@ jobs: - name: Rust Toolchain uses: actions-rs/toolchain@v1 with: - # nightly can be very volatile--pin this to a version we know works well... - toolchain: nightly-2021-08-30 + profile: minimal + toolchain: stable override: true - name: Cargo Build uses: actions-rs/cargo@v1 @@ -43,10 +35,8 @@ jobs: with: command: test args: --verbose --workspace -- --test-threads=1 - - # TODO: fix rustfmt issues - # - name: Rustfmt Check - # uses: actions-rs/cargo@v1 - # with: - # command: fmt - # args: --verbose -- --check + - name: Rustfmt Check + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --verbose -- --check diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1df29076..cee306fb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,10 +22,13 @@ jobs: uses: actions-rs/toolchain@v1 with: # nightly can be very volatile--pin this to a version we know works well... - toolchain: nightly-2021-08-30 + toolchain: nightly-2022-01-10 override: true - name: Cargo Test - # uses: actions-rs/cargo@v1 + uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace --all-features --no-fail-fast --verbose -- --test-threads=1 env: CARGO_INCREMENTAL: '0' # https://github.com/marketplace/actions/rust-grcov @@ -34,8 +37,6 @@ jobs: #RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' - run: | - cargo test --workspace --all-features --no-fail-fast --verbose -- --test-threads=1 - id: coverage name: Code Coverage uses: actions-rs/grcov@v0.1 diff --git a/build.rs b/build.rs index 6132e12e..86c42539 100644 --- a/build.rs +++ b/build.rs @@ -35,15 +35,24 @@ fn main() { // which libraries to link against and in which directories they can be found. // ion_events library - println!("cargo:rustc-link-search=native={}/build/tools/events", ion_c_release_dir); + println!( + "cargo:rustc-link-search=native={}/build/tools/events", + ion_c_release_dir + ); println!("cargo:rustc-link-lib=static=ion_events_static"); // ion_c library - println!("cargo:rustc-link-search=native={}/build/ionc", ion_c_release_dir); + println!( + "cargo:rustc-link-search=native={}/build/ionc", + ion_c_release_dir + ); println!("cargo:rustc-link-lib=static=ionc_static"); // decNumber library - println!("cargo:rustc-link-search=native={}/build/decNumber", ion_c_release_dir); + println!( + "cargo:rustc-link-search=native={}/build/decNumber", + ion_c_release_dir + ); println!("cargo:rustc-link-lib=static=decNumber_static"); // C++ library @@ -63,7 +72,10 @@ fn main() { } // ion-c CLI library - println!("cargo:rustc-link-search=native={}/build/tools/cli/", ion_c_release_dir); + println!( + "cargo:rustc-link-search=native={}/build/tools/cli/", + ion_c_release_dir + ); println!("cargo:rustc-link-lib=static=ion_cli_main"); // Only rebuild ion-c if that submodule directory is updated diff --git a/ion-c b/ion-c index a9af6be3..49494823 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit a9af6be3f2ed38d4775257adfa5672c845cac361 +Subproject commit 49494823b5c290da153fe1b4840eca581670d1ad diff --git a/src/bin/ion/commands/beta/mod.rs b/src/bin/ion/commands/beta/mod.rs index 8407468c..85809d92 100644 --- a/src/bin/ion/commands/beta/mod.rs +++ b/src/bin/ion/commands/beta/mod.rs @@ -1,26 +1,23 @@ pub mod inspect; pub mod schema; +use crate::commands::{CommandConfig, CommandRunner}; use anyhow::Result; use clap::{App, ArgMatches}; -use crate::commands::{CommandRunner, CommandConfig}; // To add a beta subcommand, add your new command to the `beta_subcommands` // and `runner_for_beta_subcommands` functions. // Creates a Vec of CLI configurations for all of the available built-in commands pub fn beta_subcommands() -> Vec { - vec![ - inspect::app(), - schema::app() - ] + vec![inspect::app(), schema::app()] } pub fn runner_for_beta_subcommand(command_name: &str) -> Option { let runner = match command_name { "inspect" => inspect::run, "schema" => schema::run, - _ => return None + _ => return None, }; Some(runner) } @@ -39,7 +36,7 @@ pub fn run(_command_name: &str, matches: &ArgMatches<'static>) -> Result<()> { "The requested beta command ('{}') is not supported and clap did not generate an error message.", command_name ); - unreachable!(message); + unreachable!("{}", message); } Ok(()) } diff --git a/src/bin/ion/commands/beta/schema/load.rs b/src/bin/ion/commands/beta/schema/load.rs index 183b0e11..8e67a36a 100644 --- a/src/bin/ion/commands/beta/schema/load.rs +++ b/src/bin/ion/commands/beta/schema/load.rs @@ -1,8 +1,8 @@ -use anyhow::{Result}; +use anyhow::Result; use clap::{App, Arg, ArgMatches}; use ion_schema::authority::{DocumentAuthority, FileSystemDocumentAuthority}; -use std::path::Path; use ion_schema::system::SchemaSystem; +use std::path::Path; const ABOUT: &str = "Loads an Ion Schema file using user provided schema id and returns a result message. Shows an error message if there were any invalid schema syntax found during the load process"; @@ -61,4 +61,3 @@ pub fn run(_command_name: &str, matches: &ArgMatches<'static>) -> Result<()> { Ok(()) } - diff --git a/src/bin/ion/commands/beta/schema/mod.rs b/src/bin/ion/commands/beta/schema/mod.rs index daa8cf19..08f14e9a 100644 --- a/src/bin/ion/commands/beta/schema/mod.rs +++ b/src/bin/ion/commands/beta/schema/mod.rs @@ -1,23 +1,21 @@ pub mod load; +use crate::commands::{CommandConfig, CommandRunner}; use anyhow::Result; use clap::{App, ArgMatches}; -use crate::commands::{CommandRunner, CommandConfig}; // To add a schema subcommand, add your new command to the `schema_subcommands` // and `runner_for_schema_subcommands` functions. // Creates a Vec of CLI configurations for all of the available built-in subcommands for schema pub fn schema_subcommands() -> Vec { - vec![ - load::app(), - ] + vec![load::app()] } pub fn runner_for_schema_subcommand(command_name: &str) -> Option { let runner = match command_name { "load" => load::run, - _ => return None + _ => return None, }; Some(runner) } @@ -35,7 +33,7 @@ pub fn run(_command_name: &str, matches: &ArgMatches<'static>) -> Result<()> { "The requested schema command ('{}') is not supported and clap did not generate an error message.", command_name ); - unreachable!(message); + unreachable!("{}", message); } Ok(()) } @@ -46,4 +44,4 @@ pub fn app() -> CommandConfig { "The 'schema' command is a namespace for commands that are related to schema sandbox", ) .subcommands(schema_subcommands()) -} \ No newline at end of file +} diff --git a/src/bin/ion/commands/dump.rs b/src/bin/ion/commands/dump.rs index 38336938..0c06c1d7 100644 --- a/src/bin/ion/commands/dump.rs +++ b/src/bin/ion/commands/dump.rs @@ -1,11 +1,11 @@ use anyhow::Result; use clap::{App, Arg, ArgMatches}; +use crate::commands::CommandConfig; use libc::c_char; use libc::c_int; use std::ffi::CString; use std::ptr; -use crate::commands::CommandConfig; // ion_c_cli_main is a C function that lives in the ion-c CLI, to which ion-cli is // statically linked. diff --git a/src/bin/ion/commands/mod.rs b/src/bin/ion/commands/mod.rs index 4357f95c..e9acc072 100644 --- a/src/bin/ion/commands/mod.rs +++ b/src/bin/ion/commands/mod.rs @@ -9,10 +9,7 @@ pub type CommandRunner = fn(&str, &ArgMatches<'static>) -> Result<()>; // Creates a Vec of CLI configurations for all of the available built-in commands pub fn built_in_commands() -> Vec { - vec![ - dump::app(), - beta::app() - ] + vec![dump::app(), beta::app()] } // Maps the given command name to the entry point for that command if it exists diff --git a/src/bin/ion/main.rs b/src/bin/ion/main.rs index 738c1ba7..26e7ab45 100644 --- a/src/bin/ion/main.rs +++ b/src/bin/ion/main.rs @@ -1,7 +1,7 @@ mod commands; -use anyhow::Result; use crate::commands::{built_in_commands, runner_for_built_in_command}; +use anyhow::Result; use clap::{crate_authors, crate_version, App, AppSettings}; const PROGRAM_NAME: &str = "ion"; @@ -29,7 +29,7 @@ fn main() -> Result<()> { "The requested command ('{}') is not supported and clap did not generate an error message.", command_name ); - unreachable!(message); + unreachable!("{}", message); } Ok(()) } diff --git a/tests/cli.rs b/tests/cli.rs index d71c2e7c..f6daa759 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use assert_cmd::Command; use ion_rs::value::owned::OwnedElement; use ion_rs::value::reader::*; use rstest::*; @@ -6,7 +7,6 @@ use std::fs::File; use std::io::{Read, Write}; use std::time::Duration; use tempfile::TempDir; -use assert_cmd::Command; enum FileMode { /// Use `STDIN` or `STDOUT` @@ -28,7 +28,7 @@ impl From<(&'static str, &'static str)> for TestCase<&'static str> { let expected_ion = element_reader().read_one(expected_ion.as_bytes()).unwrap(); Self { ion_text, - expected_ion + expected_ion, } } } @@ -74,14 +74,13 @@ r#" ).into())] fn run_it>( #[case] test_case: TestCase, -#[values("", "binary", "text", "pretty")] format_flag: &str, -#[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, -#[values(FileMode::Default, FileMode::Named)] output_mode: FileMode + #[values("", "binary", "text", "pretty")] format_flag: &str, + #[values(FileMode::Default, FileMode::Named)] input_mode: FileMode, + #[values(FileMode::Default, FileMode::Named)] output_mode: FileMode, ) -> Result<()> { - let TestCase { ion_text, - expected_ion + expected_ion, } = test_case; let temp_dir = TempDir::new()?; @@ -97,7 +96,7 @@ fn run_it>( match output_mode { FileMode::Default => { // do nothing - }, + } FileMode::Named => { // tell driver to output to a file cmd.arg("-o"); @@ -109,7 +108,7 @@ fn run_it>( FileMode::Default => { // do nothing cmd.write_stdin(ion_text.as_ref()); - }, + } FileMode::Named => { // dump our test data to input file let mut input_file = File::create(&input_path)?; @@ -120,7 +119,6 @@ fn run_it>( // make this the input for our driver cmd.arg(input_path.to_str().unwrap()); - } }; From 0534da9a893288e94350c245a2ac3be6304345b0 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 01:00:47 -0700 Subject: [PATCH 29/34] Add test comment, revert ion-c commits, remove failing coverage test for now --- .github/workflows/build.yml | 9 ++++++- .github/workflows/coverage.yml | 46 ---------------------------------- ion-c | 2 +- tests/cli.rs | 2 ++ 4 files changed, 11 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee5efcb1..926aa3ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,16 @@ jobs: strategy: matrix: # TODO: add windows after fixing build issues - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-2019] steps: + - name: Remove MSys64 MingW64 Binaries + if: runner.os == 'Windows' + # remove this because there is a bad libclang.dll that confuses bindgen + run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse + - name: Install Dependencies + if: runner.os == 'Windows' + run: choco install llvm -y - name: Git Checkout uses: actions/checkout@v2 with: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index cee306fb..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Code Coverage - # original source: https://github.com/amzn/ion-rust/blob/main/.github/workflows/coverage.yml -on: [push, pull_request] - -jobs: - build: - name: Build and Test - runs-on: ${{ matrix.os }} - # We want to run on external PRs, but not on internal ones as push automatically builds - # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-cli' - strategy: - matrix: - os: [ubuntu-latest] - - steps: - - name: Git Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - # nightly can be very volatile--pin this to a version we know works well... - toolchain: nightly-2022-01-10 - override: true - - name: Cargo Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --workspace --all-features --no-fail-fast --verbose -- --test-threads=1 - env: - CARGO_INCREMENTAL: '0' - # https://github.com/marketplace/actions/rust-grcov - # For some reason the panic=abort modes don't work for build script... - #RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - #RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' - - id: coverage - name: Code Coverage - uses: actions-rs/grcov@v0.1 - - name: Codecov Upload - uses: codecov/codecov-action@v1 - with: - files: ${{ steps.coverage.outputs.report }} diff --git a/ion-c b/ion-c index 49494823..a1a953c7 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit 49494823b5c290da153fe1b4840eca581670d1ad +Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 diff --git a/tests/cli.rs b/tests/cli.rs index f6daa759..f15e3c13 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -72,6 +72,8 @@ r#" } "# ).into())] +/// Calls the ion CLI binary dump command with a set of arguments the ion-cli is expected to support. +/// This does not verify specific formatting, only basic CLI behavior. fn run_it>( #[case] test_case: TestCase, #[values("", "binary", "text", "pretty")] format_flag: &str, From 4b38b93183678357c328c37c8694750195889a94 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 02:20:20 -0700 Subject: [PATCH 30/34] try updating ion-c submodule to resolve windows build error --- .github/workflows/build.yml | 2 +- ion-c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 926aa3ac..0c6b91e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: # TODO: add windows after fixing build issues - os: [ubuntu-latest, macos-latest, windows-2019] + os: [ubuntu-latest, windows-2019, macos-latest] steps: - name: Remove MSys64 MingW64 Binaries diff --git a/ion-c b/ion-c index a1a953c7..49494823 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 +Subproject commit 49494823b5c290da153fe1b4840eca581670d1ad From 20204c970bff8d424695a8e9085ddb5ec2295001 Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 02:37:35 -0700 Subject: [PATCH 31/34] revert ion-c commits to match main branch --- ion-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ion-c b/ion-c index 49494823..a1a953c7 160000 --- a/ion-c +++ b/ion-c @@ -1 +1 @@ -Subproject commit 49494823b5c290da153fe1b4840eca581670d1ad +Subproject commit a1a953c7315a80c124269e5d2392fe5fe60bef04 From a40992d7ba38925cfd09cafdf22dac1cc63f25cc Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 02:56:29 -0700 Subject: [PATCH 32/34] Remove Windows build due to CMake build failure --- .github/workflows/build.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c6b91e3..81441e62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,17 +11,11 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amzn/ion-cli' strategy: matrix: - # TODO: add windows after fixing build issues - os: [ubuntu-latest, windows-2019, macos-latest] + # TODO: add windows after fixing cmake version error issues + # see for example Windows build workflow: https://github.com/amzn/ion-rust/blob/a4b154cc0a5b5b661a45ac14d3719a501573d8f2/.github/workflows/rust.yml#L13-L28 + os: [ubuntu-latest, macos-latest] steps: - - name: Remove MSys64 MingW64 Binaries - if: runner.os == 'Windows' - # remove this because there is a bad libclang.dll that confuses bindgen - run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse - - name: Install Dependencies - if: runner.os == 'Windows' - run: choco install llvm -y - name: Git Checkout uses: actions/checkout@v2 with: From d3f7faa1581d2f8105a3ca15247657af7bd732fc Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 03:09:26 -0700 Subject: [PATCH 33/34] try with windows latest --- .github/workflows/build.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81441e62..68e515ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,9 +13,16 @@ jobs: matrix: # TODO: add windows after fixing cmake version error issues # see for example Windows build workflow: https://github.com/amzn/ion-rust/blob/a4b154cc0a5b5b661a45ac14d3719a501573d8f2/.github/workflows/rust.yml#L13-L28 - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: Remove MSys64 MingW64 Binaries + if: runner.os == 'Windows' + # remove this because there is a bad libclang.dll that confuses bindgen + run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse + - name: Install Dependencies + if: runner.os == 'Windows' + run: choco install llvm -y - name: Git Checkout uses: actions/checkout@v2 with: From 6992c9822cf1515984a024b579900688199a001f Mon Sep 17 00:00:00 2001 From: Cameron Durham Date: Tue, 1 Mar 2022 09:04:45 -0700 Subject: [PATCH 34/34] remove windows build for now --- .github/workflows/build.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68e515ab..81441e62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,16 +13,9 @@ jobs: matrix: # TODO: add windows after fixing cmake version error issues # see for example Windows build workflow: https://github.com/amzn/ion-rust/blob/a4b154cc0a5b5b661a45ac14d3719a501573d8f2/.github/workflows/rust.yml#L13-L28 - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, macos-latest] steps: - - name: Remove MSys64 MingW64 Binaries - if: runner.os == 'Windows' - # remove this because there is a bad libclang.dll that confuses bindgen - run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse - - name: Install Dependencies - if: runner.os == 'Windows' - run: choco install llvm -y - name: Git Checkout uses: actions/checkout@v2 with: