Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 85 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
FROM debian:bookworm-slim AS builder
# To refresh, copy the Digest from
# `docker buildx imagetools inspect cgr.dev/chainguard/wolfi-base:latest`
ARG WOLFI_BASE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31

RUN apt-get update && apt-get install -y --no-install-recommends \
bash curl git g++ make wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
FROM ${WOLFI_BASE} AS builder

# build-base bundles gcc/g++, make and glibc-dev (for the C++ side
# of Factor's VM); the rest fetch + bootstrap the source tree.
RUN apk add --no-cache bash build-base curl git wget

# Factor 0.101
ARG FACTOR_COMMIT="a56e6390e81340be6573cb790311c0a980a5f369"

WORKDIR /opt
RUN git clone https://github.com/factor/factor.git && \
cd factor && \
git checkout cd14ceed53f6f9a43bbd3aec3950d8beb5439ed8
git checkout ${FACTOR_COMMIT}
WORKDIR /opt/factor
RUN ./build.sh update

Expand All @@ -17,12 +24,80 @@ RUN rm -rf .git build vm src misc Factor.app \
extra GNUmakefile Nmakefile LICENSE.txt README.md \
build.sh build.cmd unmaintained

FROM debian:bookworm-slim
# Prune basis subdirs that exercism tests cannot reach. Source files only —
# the precompiled bytecode for these is in factor.image, which is unaffected.
# - GUI and graphics: ui, opengl, cairo, gdk2/3/4, gtk2/3/4, gdk-pixbuf, gsk4,
# glib, gmodule, gobject, gio, graphene, atk, gobject-introspection, gir,
# pango, x11, fonts, images
# - macOS-specific: cocoa, core-foundation, core-graphics, core-text, iokit
# - Windows-specific: windows
# - Linux-specific: linux
# - Networking, RPC, web: dns, ftp, html, http, mime, oauth1, oauth2, openssl,
# resolv-conf, smtp, syndication, urls, webbrowser, xml, xml-rpc
# - Data formats: cbor, csv, ini-file, json, msgpack, pack, quoted-printable,
# serialize, toml, uu
# - Persistence / db: couchdb, db
# - Encoding / hashing / compression: base16, base24, base32, base36, base45,
# base58, base62, base64, base85, base91, base92, checksums, compression,
# crypto, hex-strings
# - Specialised data structures with no exercise use: biassocs, bit-arrays,
# bit-sets, bit-vectors, bitstreams, bloom-filters, boxes, circular,
# columns, cuckoo-filters, disjoint-sets, dlists, heaps, interval-maps,
# interval-sets, lazy, linked-assocs, linked-sets, lists, named-tuples,
# nibble-arrays, reservoir-sampling, search-deques, specialized-arrays,
# specialized-vectors, suffix-arrays, tuple-arrays, unrolled-lists, vlists
# - Pattern, parsing, text utilities: globs, lcs, match, peg,
# porter-stemmer, regexp, simple-tokenizer, tr, wrap
# - Editor / interactive only: documents, inspector, listener, see, xdg
# - Other unused: xmode (syntax highlighting), game, farkup (markup),
# calendar, colors, delegate, escape-strings, etc-hosts, eval, interpolate,
# ip-parser, logging, memoize, method-chains, mirrors, models, nmake, ntp,
# protocols, quoting, refs, retries, roman, simple-flat-file, system-info,
# timers, typed, uuid, validators
RUN cd basis && rm -rf \
atk cairo cocoa core-foundation core-graphics core-text fonts \
farkup game gdk2 gdk3 gdk4 gdk-pixbuf gio gir glib gmodule \
gobject gobject-introspection graphene gsk4 gtk2 gtk3 gtk4 \
images iokit linux opengl pango ui windows x11 xmode \
editors furnace help \
dns ftp html http mime oauth1 oauth2 openssl resolv-conf smtp \
syndication urls webbrowser xml xml-rpc \
cbor csv ini-file json msgpack pack quoted-printable serialize toml uu \
couchdb db \
base16 base24 base32 base36 base45 base58 base62 base64 base85 base91 \
base92 checksums compression crypto hex-strings \
biassocs bit-arrays bit-sets bit-vectors bitstreams bloom-filters boxes \
circular columns cuckoo-filters disjoint-sets dlists heaps \
interval-maps interval-sets lazy linked-assocs linked-sets lists \
named-tuples nibble-arrays reservoir-sampling search-deques \
specialized-arrays specialized-vectors suffix-arrays tuple-arrays \
unrolled-lists vlists \
globs lcs match peg porter-stemmer regexp simple-tokenizer tr wrap \
documents inspector listener see xdg \
calendar colors delegate escape-strings etc-hosts eval interpolate \
ip-parser logging memoize method-chains mirrors models nmake ntp \
protocols quoting refs retries roman simple-flat-file system-info \
timers typed uuid validators \
bootstrap environment persistent random

# Asian and rare encodings: only utf8 / latin1 / strict are kept (everything
# bundled streams use). 8-bit is the multi-codepage non-utf umbrella.
RUN cd basis/io/encodings && rm -rf \
8-bit big5 euc euc-jp euc-kr gb18030 iso2022 johab shift-jis utf32 utf7

# Drop *-docs.factor — only used by Factor's interactive help browser.
# *-tests.factor and tags.txt / summary.txt / authors.txt are kept: Factor's
# vocab loader and `test` word reference them and removing them breaks
# at least basis/binary-search at runtime.
RUN find . -name '*-docs.factor' -delete


FROM ${WOLFI_BASE}

RUN apt-get update && apt-get install -y --no-install-recommends \
bash jq coreutils libstdc++6 \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
/usr/share/zoneinfo /usr/share/perl5 /var/lib/dpkg /var/cache
# bash for run.sh
# coreutils for realpath / mktemp
# gawk + jq for the parser
RUN apk add --no-cache bash coreutils gawk jq libstdc++

COPY --from=builder /opt/factor /opt/factor
ENV PATH="/opt/factor:${PATH}" \
Expand Down
17 changes: 8 additions & 9 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh

# Synopsis:
# Test the test runner by running it against a predefined set of solutions
# Test the test runner by running it against a predefined set of solutions
# with an expected output.

# Output:
Expand All @@ -13,20 +13,19 @@

exit_code=0

# Iterate over all test directories
# Iterate over all test directories. bin/run.py copies each fixture to its own
# temp dir before running Factor, so the committed fixture files are not
# mutated. results.json is written to the fixture dir for post-run
# investigation (gitignored).
for test_dir in tests/*; do
test_dir_name=$(basename "${test_dir}")
test_dir_path=$(realpath "${test_dir}")

bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"

# Normalize paths in results to match Docker environment
file="results.json"
sed -i "s~${test_dir_path}~/opt/test-runner/tests/${test_dir_name}~g" "${test_dir_path}/${file}"
expected_file="expected_${file}"
echo "${test_dir_name}: comparing ${file} to ${expected_file}"

if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
expected_file="expected_results.json"
echo "${test_dir_name}: comparing results.json to ${expected_file}"
if ! diff "${test_dir_path}/results.json" "${test_dir_path}/${expected_file}"; then
exit_code=1
fi
done
Expand Down
Loading
Loading