Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0]: Swift 6 support #58

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM swift:5.8-bionic AS builder
FROM swift:6.0.2 AS builder
# WORKDIR /opt/testrunner
COPY src/testrunner ./

Expand All @@ -7,7 +7,7 @@ RUN swift --version
#RUN swift package clean
RUN swift build --configuration release

FROM swift:5.8-bionic
FROM swift:6.0.2
RUN apt-get update && apt-get install -y jq
WORKDIR /opt/test-runner/
COPY bin/ bin/
Expand Down
39 changes: 39 additions & 0 deletions bin/benchmark-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# Synopsis:
# Benchmark the test runner Docker image.
# Each run will clean the test directory being used to prevent previous runs from affecting the results.

# Environment:
# SKIP_DOCKER_BUILD: if set, skip building the Docker image

# Output:
# Outputs performance metrics.

# Example:
# ./bin/benchmark-in-docker.sh

set -eo pipefail

die() { echo "$*" >&2; exit 1; }

required_tool() {
command -v "${1}" >/dev/null 2>&1 ||
die "${1} is required but not installed. Please install it and make sure it's in your PATH."
}

required_tool docker
required_tool hyperfine

# Pre-build the Docker image
if [ -z "${SKIP_DOCKER_BUILD}" ]; then
docker build --rm -t exercism/replace-this-with-the-track-slug-test-runner .
else
echo "Skipping docker build because SKIP_DOCKER_BUILD is set."
fi

CURRENT_PATH=$(pwd)

hyperfine \
--parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \
"SKIP_DOCKER_BUILD=true bin/run-in-docker.sh {slug} $CURRENT_PATH/tests/{slug} $CURRENT_PATH/tests/{slug}" \
27 changes: 27 additions & 0 deletions bin/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Synopsis:
# Benchmark the test runner code.
# Each run will clean the test directory being used to prevent previous runs from affecting the results.

# Output:
# Outputs performance metrics.

# Example:
# ./bin/benchmark.sh

set -eo pipefail

die() { echo "$*" >&2; exit 1; }

required_tool() {
command -v "${1}" >/dev/null 2>&1 ||
die "${1} is required but not installed. Please install it and make sure it's in your PATH."
}

required_tool hyperfine

hyperfine \
--parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \
--prepare 'git clean -xdfq tests/{slug}' \
'bin/run.sh {slug} tests/{slug} tests/{slug}'
5 changes: 2 additions & 3 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ fi
SLUG="$1"
INPUT_DIR="${2%/}"
OUTPUT_DIR="${3%/}"
junit_file="${INPUT_DIR}/results.xml"
junit_file="${INPUT_DIR}/results-swift-testing.xml"
capture_file="${OUTPUT_DIR}/capture"
spec_file="${INPUT_DIR}/$(jq -r '.files.test[0]' ${INPUT_DIR}/.meta/config.json)"
results_file="${OUTPUT_DIR}/results.json"
BASEDIR=$(dirname "$0")

touch "${results_file}"

export RUNALL=true
swift test --package-path "${INPUT_DIR}" -v --parallel --num-workers 1 --xunit-output "${junit_file}" &> "${capture_file}"
swift test --package-path "${INPUT_DIR}" --xunit-output "${INPUT_DIR}/results.xml" &> "${capture_file}"


./bin/TestRunner "${spec_file}" "${junit_file}" "${capture_file}" "${results_file}" "${SLUG}"
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.0.0

- Updated to Swift 6.1
- Update swift-syntax to 600.0.0
- Use swift-testing instead of XCTest
- Brand new way of handling gathering test results, which is more robust and easier to maintain
- Depricated task_id, user output
- Uses version 2 instead of 3

# 1.1.3

- Fixed an issue making so outputs on multiple lines missed the last line
Expand Down
2 changes: 1 addition & 1 deletion src/testrunner/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-syntax.git", exact: "508.0.1")
.package(url: "https://github.com/apple/swift-syntax.git", exact: "600.0.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Loading
Loading