diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20c1727..96432a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,6 @@ on: jobs: run: - runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -47,89 +46,22 @@ jobs: - smalltalk # - tcl - zig + runs-on: ubuntu-latest + container: + image: acheronfail/count steps: - name: Checkout uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - target/ - key: ${{ runner.os }}-cargo - - uses: actions/cache@v3 - with: - path: scripts/node_modules - key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} - # install dependencies - - uses: extractions/setup-just@v1 - - uses: oven-sh/setup-bun@v1 - - uses: denoland/setup-deno@v1 - with: - deno-version: "~1" - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - build-essential \ - cargo \ - clang \ - coffeescript \ - curl \ - erlang \ - fp-compiler \ - gforth \ - gfortran \ - gnu-smalltalk \ - gnucobol3 \ - haskell-platform \ - jq \ - kotlin \ - lua5.4 \ - mono-devel \ - moreutils \ - nasm \ - nodejs \ - php \ - rustc \ - scala \ - swi-prolog \ - tar \ - tcl \ - wget \ - xz-utils - cargo install timers - cargo install hyperfine - cargo install ripgrep --features 'pcre2' - cargo install juliaup - - juliaup add release - - wget -qO choosenim.sh https://nim-lang.org/choosenim/init.sh - bash ./choosenim.sh -y - echo "$HOME/.nimble/bin" >> $GITHUB_PATH - export PATH="$HOME/.nimble/bin:$PATH" - - curl -fsSL https://crystal-lang.org/install.sh | sudo bash - - mkdir -p /opt/zig && cd $_ - wget --quiet -O zig.tar.xz $(curl --silent https://ziglang.org/download/index.json | jq -r '.[keys_unsorted[1]]["x86_64-linux"].tarball') - tar -xvf zig.tar.xz --strip-components=1 2>&1 >/dev/null - echo "/opt/zig" >> $GITHUB_PATH - export PATH="/opt/zig:$PATH" - cd - - + # really github? why do you override $HOME? + # https://github.com/actions/runner/issues/863 + - run: 'echo HOME=/root >> $GITHUB_ENV' # do the thing - run: just test ${{ matrix.build }} - run: just measure ${{ matrix.build }} # report - uses: actions/upload-artifact@v3 with: - path: "${{ matrix.build }}.json" + path: "results/${{ matrix.build }}.json" report: needs: ["run"] @@ -145,8 +77,7 @@ jobs: - name: Generate Summary run: | cd scripts - npm install - node ./summary.js --results ../artifact > summary.txt + npm start -- --results ../artifact > summary.txt cat summary.txt - uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index 4be3e99..9b35f66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ build -results +results/*.json *.out *.dump *.beam @@ -13,4 +13,5 @@ java/ kotlin/ scala/ CMD -VERSION \ No newline at end of file +VERSION +STATS \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6850388..d75ae8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,67 +1,43 @@ FROM ubuntu:latest ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" -RUN apt-get update && apt-get install -y \ - build-essential clang curl jq moreutils sudo tar unzip wget xz-utils -RUN useradd -m runner && echo "runner ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/runner -USER runner +RUN apt-get update && apt-get install -y \ + build-essential clang coffeescript curl default-jdk default-jre erlang \ + fp-compiler gdb lldb gforth gfortran git gnu-smalltalk gnucobol3 golang \ + haskell-platform jq kotlin lua5.4 mono-complete moreutils nasm php ruby \ + scala swi-prolog tar tcl unzip wget xz-utils \ + && apt-get clean +RUN curl -fSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs -RUN curl \ - -sSfL \ - --proto '=https' \ - --tlsv1.2 \ - https://sh.rustup.rs | sh -s -- --default-toolchain stable -y +RUN curl -fSL https://sh.rustup.rs | sh -s -- -y --default-toolchain stable +ENV PATH="/root/.cargo/bin:$PATH" -RUN curl \ - -sSfL \ - --proto '=https' \ - --tlsv1.2 \ - https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +RUN curl -fSL \ + https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh \ + | bash +RUN cargo install ripgrep --features pcre2 +RUN cargo binstall --no-confirm hyperfine just timers juliaup -ENV PATH="/home/runner/.cargo/bin:$PATH" -RUN cargo binstall --no-confirm hyperfine just ripgrep timers +RUN juliaup add release -RUN cargo binstall --no-confirm juliaup && juliaup add release -RUN curl -fsSL https://bun.sh/install | bash -RUN curl -fsSL https://deno.land/x/install/install.sh | sh -RUN sudo -E apt-get install -y coffeescript -RUN sudo -E apt-get install -y erlang -RUN sudo -E apt-get install -y fp-compiler -RUN sudo -E apt-get install -y gforth -RUN sudo -E apt-get install -y gfortran -RUN sudo -E apt-get install -y gnu-smalltalk -RUN sudo -E apt-get install -y gnucobol3 -RUN sudo -E apt-get install -y haskell-platform -RUN sudo -E apt-get install -y kotlin -RUN sudo -E apt-get install -y lua5.4 -RUN sudo -E apt-get install -y nasm -RUN sudo -E apt-get install -y nodejs -RUN sudo -E apt-get install -y php -RUN sudo -E apt-get install -y scala -RUN sudo -E apt-get install -y swi-prolog -RUN sudo -E apt-get install -y tcl +RUN curl -fSL https://bun.sh/install | bash +ENV PATH="/root/.bun/bin:$PATH" -RUN curl -fsSL https://crystal-lang.org/install.sh | sudo bash +RUN curl -fSL https://deno.land/x/install/install.sh | sh +ENV PATH="/root/.deno/bin:$PATH" -RUN curl \ - -sSfL \ - --proto '=https' \ - --tlsv1.2 \ - https://nim-lang.org/choosenim/init.sh | sh -s -- -y -ENV PATH="/home/runner/.nimble/bin:$PATH" +RUN curl -fSL https://crystal-lang.org/install.sh | bash -RUN sudo mkdir -p /opt/zig && cd $_ && \ - wget \ - --quiet \ - -O zig.tar.xz \ - $(curl --silent https://ziglang.org/download/index.json | jq -r '.[keys_unsorted[1]]["x86_64-linux"].tarball') && \ - tar -xvf zig.tar.xz --strip-components=1 2>&1 >/dev/null -ENV PATH="/opt/zig:$PATH" +RUN curl -fSL https://nim-lang.org/choosenim/init.sh | sh -s -- -y +ENV PATH="/root/.nimble/bin:$PATH" -# FIXME: https://github.com/mono/mono/issues/21423 -# installing gdb/lldb provide a better error message when mono-devel fails to install -RUN sudo -E apt-get install -y gdb lldb -RUN sudo -E apt-get install -y mono-complete +RUN cd && curl -fSL "$(curl -fSL https://ziglang.org/download/index.json | jq -r '.[keys_unsorted[1]]["x86_64-linux"].tarball')" \ + > zig.tar.xz \ + && mkdir -p "/root/.zig" \ + && tar -xvf zig.tar.xz --strip-components=1 -C "/root/.zig" \ + && rm zig.tar.xz +ENV PATH="/root/.zig:$PATH" -# TODO: when this docker image works, get CI to use it \ No newline at end of file +WORKDIR /var/count diff --git a/justfile b/justfile index c18d83a..9337fc6 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,6 @@ i := '1000000000' +tag := 'acheronfail/count' +mount := '/var/count' _default: just -l @@ -9,18 +11,37 @@ _default: setup: (_check "npm") cd scripts && npm install -docker-amd64: - docker run --rm -ti --platform 'linux/amd64' -v "$PWD:/data" ubuntu:22.04 bash +docker-sh: + docker run --rm -ti --platform 'linux/amd64' -v "$PWD:{{mount}}" {{tag}} -build-docker: - docker build --platform 'linux/amd64' -t count . +# NOTE: there are issues if you try to build this on an arm macbook via rosetta emulation +# - mono fails to install (https://github.com/mono/mono/issues/21423) +# - getting erlang version segfaults +docker-build: + docker build --progress=plain --platform 'linux/amd64' -t {{tag}} . -# just checks if mono can be installed in docker, since there's an issue with it -# currently preventing us from shipping this docker image properly -# see: https://github.com/mono/mono/issues/21423 -check-docker: - docker run --rm -ti --platform 'linux/amd64' ubuntu \ - sh -c 'apt update && DEBIAN_FRONTEND=noninteractive TZ="Europe/London" apt install -y mono-complete' +docker-pull: + docker pull {{tag}} + +docker-push: docker-build + docker push {{tag}} + +docker-measure what: + docker run --rm -ti --platform 'linux/amd64' -v "$PWD:{{mount}}" {{tag}} just measure {{what}} + +docker-measure-all: + docker run --rm -ti --platform 'linux/amd64' -v "$PWD:{{mount}}" {{tag}} just measure-all + +measure-all: + #!/usr/bin/env bash + set -exuo pipefail + + for lang in $(just -l | grep 'build-' | cut -d'-' -f2- | xargs); do + just test "$lang"; + just measure "$lang"; + done + + cd scripts && npm start build what: rm -f CMD VERSION @@ -33,9 +54,7 @@ run what: measure what: #!/usr/bin/env bash set -euxo pipefail - just build {{what}} - slow_langs=( cobol haskell @@ -57,18 +76,21 @@ measure what: fi done - out="{{what}}.json" + mkdir -p results + out="results/{{what}}.json" hyperfine $args --shell=none --export-json "$out" "$(cat CMD)" jq '.results[0] | del(.exit_codes)' "$out" | sponge "$out" jq '. += {"name":"{{what}}","version":"'"$(cat VERSION)"'"}' "$out" | sponge "$out" - timers $(cat CMD) >/dev/null 2> >(jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1')'}' "$out" | sponge "$out") + timers $(cat CMD) >/dev/null 2> STATS + jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1' ./STATS)'}' "$out" | sponge "$out" -summary results: - cd scripts && node ./summary.js --results .. +summary: + cd scripts && npm start -- --results ../results test what: #!/usr/bin/env bash + set -euo pipefail just build {{what}} tests=( 1 1 diff --git a/results/.gitkeep b/results/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/package.json b/scripts/package.json index 5788663..754559a 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -1,5 +1,8 @@ { "type": "module", + "scripts": { + "start": "npm install && node summary.js" + }, "dependencies": { "human-readable": "^0.2.1", "minimist": "^1.2.8",