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

CI: consolidate GH action cache #1181

Merged
merged 14 commits into from
Dec 14, 2023
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
13 changes: 6 additions & 7 deletions .github/workflows/rtx.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: rtx

name: test
on:
push:
tags: ["v*"]
Expand Down Expand Up @@ -29,8 +28,9 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
- uses: Swatinem/rust-cache@v2
with:
shared-key: unit
save-if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
shared-key: test
save-if: ${{ github.ref_name == 'main' }}
cache-all-crates: true
- uses: taiki-e/install-action@v2
with:
tool: nextest,just,cargo-deny,cargo-msrv,cargo-machete
Expand Down Expand Up @@ -70,9 +70,8 @@ jobs:
#- run: rustup toolchain install nightly --component llvm-tools-preview --profile minimal
- uses: Swatinem/rust-cache@v2
with:
shared-key: coverage
save-if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-all-crates: true
shared-key: test
save-if: false
- run: sudo apt-get update; sudo apt-get install zsh fish direnv shfmt
- run: npm i -g markdown-magic
- uses: taiki-e/install-action@v2
Expand Down
15 changes: 11 additions & 4 deletions e2e/cd/test_bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,31 @@ assert_path() {
fi
}

NODE_18="INSTALLS/node/18.0.0/bin"
NODE_20="INSTALLS/node/20.0.0/bin"
TINY="INSTALLS/tiny/3.1.0/bin"
SHELLCHECK="INSTALLS/shellcheck/0.9.0/bin"
SHFMT="INSTALLS/shfmt/3.6.0/bin"

rtx ls
rtx i && _rtx_hook
test "$(node -v)" = "v20.0.0"
assert_path "/root:ROOT/e2e/cwd:INSTALLS/node/20.0.0/bin:INSTALLS/python/3.12.0/bin:INSTALLS/tiny/3.1.0/bin:INSTALLS/poetry/1.7.1/bin:INSTALLS/shellcheck/0.9.0/bin:INSTALLS/shfmt/3.6.0/bin"
assert_path "/root:ROOT/e2e/cwd:$NODE_20:$TINY:$SHELLCHECK:$SHFMT"
assert "$FOO" "cd"

cd 18 && rtx i && _rtx_hook
test "$(node -v)" = "v18.0.0"
assert_path "/root:ROOT/e2e/cwd:INSTALLS/node/18.0.0/bin:INSTALLS/python/3.12.0/bin:INSTALLS/tiny/3.1.0/bin:INSTALLS/poetry/1.7.1/bin:INSTALLS/shellcheck/0.9.0/bin:INSTALLS/shfmt/3.6.0/bin"
assert_path "/root:ROOT/e2e/cwd:$NODE_18:$TINY:$SHELLCHECK:$SHFMT"
assert "$FOO" "18"

cd .. && _rtx_hook
test "$(node -v)" = "v20.0.0"
assert_path "/root:ROOT/e2e/cwd:INSTALLS/node/20.0.0/bin:INSTALLS/python/3.12.0/bin:INSTALLS/tiny/3.1.0/bin:INSTALLS/poetry/1.7.1/bin:INSTALLS/shellcheck/0.9.0/bin:INSTALLS/shfmt/3.6.0/bin"
assert_path "/root:ROOT/e2e/cwd:$NODE_20:$TINY:$SHELLCHECK:$SHFMT"

export PATH="PRE:$PATH"
cd 18 && _rtx_hook
test "$(node -v)" = "v18.0.0"
assert_path "PRE:/root:ROOT/e2e/cwd:INSTALLS/node/18.0.0/bin:INSTALLS/python/3.12.0/bin:INSTALLS/tiny/3.1.0/bin:INSTALLS/poetry/1.7.1/bin:INSTALLS/shellcheck/0.9.0/bin:INSTALLS/shfmt/3.6.0/bin"
assert_path "PRE:/root:ROOT/e2e/cwd:$NODE_18:$TINY:$SHELLCHECK:$SHFMT"

rtx shell [email protected] && _rtx_hook
test "$(node -v)" = "v18.0.0"
Expand Down
4 changes: 1 addition & 3 deletions e2e/config/.e2e.rtx.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ env_path = ["/root", "./cwd"]
FOO = "bar"

[tools]
python = "3.12.0"
tiny = "latest"
poetry = {version="1.7.1", pyproject="pyproject.toml"}
#golang = {version="1.19.5", foo="bar"}

[plugins]
tiny-ref = "https://github.com/rtx-plugins/rtx-tiny#df03b6719dd465d565bb66273942c8495673eaa4"
tiny-ref = "https://github.com/rtx-plugins/rtx-tiny#c532b140abd4ca00d3e76651b9bd32a980bd483c"
6 changes: 6 additions & 0 deletions e2e/run_all_tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
FILES=$(find e2e -name 'test_*' -type f -not -path "*/.rtx/*" | sort)
test_count=0
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
{
echo "| Test | Duration | Result |"
echo "| ---- | -------- | ------ |"
} >>"$GITHUB_STEP_SUMMARY"
fi
for f in $FILES; do
# split tests into two tranches to reduce test time
if [ -n "${TEST_TRANCHE_COUNT:-}" ]; then
Expand Down
16 changes: 14 additions & 2 deletions e2e/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ setup_env() {
export RTX_DEFAULT_TOOL_VERSIONS_FILENAME=.e2e-tool-versions
export RTX_DEFAULT_CONFIG_FILENAME=.e2e.rtx.toml
export RTX_CONFIG_FILE="$ROOT/e2e/.config/rtx/config.toml"
export RTX_ALWAYS_KEEP_DOWNLOAD="1"
export RTX_TRUSTED_CONFIG_PATHS="$ROOT/e2e"
export RTX_YES="1"
export NPM_CONFIG_FUND="false"
Expand All @@ -30,15 +31,26 @@ setup_config_files() {
}

run_test() {
echo "Running $TEST"
echo "::group::E2E $TEST"
rm -f "$RTX_CONFIG_FILE"
cd "$(dirname "$TEST")"

START=$(date +%s)
"./$(basename "$TEST")"
local status=0
"./$(basename "$TEST")" || status=$?
END=$(date +%s)

if [[ "$status" == 0 ]]; then
STATUS_MSG=":white_check_mark:"
else
echo "::error file=$TEST::E2E Test Failed (code: $status)"
STATUS_MSG=":x:"
fi
echo "$TEST: $((END - START))s"
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
echo "| $TEST | $((END - START))s | $STATUS_MSG" >>"$GITHUB_STEP_SUMMARY"
fi
return "$status"
}

setup_env
Expand Down
4 changes: 2 additions & 2 deletions e2e/test_bun
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ source "$(dirname "$0")/assert.sh"
export RTX_EXPERIMENTAL=1

cat <<EOF >.bun-version
0.7.0
1.0.17
EOF
rtx i bun
assert_contains "rtx x bun -- bun -v" "0.7.0"
assert_contains "rtx x bun -- bun -v" "1.0.17"
rm .bun-version
16 changes: 4 additions & 12 deletions e2e/test_local
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ env_path = [\"/root\", \"./cwd\"]
FOO = \"bar\"

[tools]
python = \"3.12.0\"
tiny = \"latest\"
poetry = {version=\"1.7.1\", pyproject=\"pyproject.toml\"}
#golang = {version=\"1.19.5\", foo=\"bar\"}

[plugins]
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#df03b6719dd465d565bb66273942c8495673eaa4\"
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#c532b140abd4ca00d3e76651b9bd32a980bd483c\"
"

rtx local [email protected]
Expand All @@ -42,14 +40,12 @@ env_path = [\"/root\", \"./cwd\"]
FOO = \"bar\"

[tools]
python = \"3.12.0\"
tiny = \"latest\"
poetry = {version=\"1.7.1\", pyproject=\"pyproject.toml\"}
shfmt = \"3.5.0\"
#golang = {version=\"1.19.5\", foo=\"bar\"}

[plugins]
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#df03b6719dd465d565bb66273942c8495673eaa4\"
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#c532b140abd4ca00d3e76651b9bd32a980bd483c\"
"

rtx exec -- shfmt --version >&2
Expand All @@ -65,14 +61,12 @@ env_path = [\"/root\", \"./cwd\"]
FOO = \"bar\"

[tools]
python = \"3.12.0\"
tiny = \"latest\"
poetry = {version=\"1.7.1\", pyproject=\"pyproject.toml\"}
shfmt = \"3.6.0\"
#golang = {version=\"1.19.5\", foo=\"bar\"}

[plugins]
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#df03b6719dd465d565bb66273942c8495673eaa4\"
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#c532b140abd4ca00d3e76651b9bd32a980bd483c\"
"

rtx exec -- shfmt --version >&2
Expand All @@ -88,13 +82,11 @@ env_path = [\"/root\", \"./cwd\"]
FOO = \"bar\"

[tools]
python = \"3.12.0\"
tiny = \"latest\"
poetry = {version=\"1.7.1\", pyproject=\"pyproject.toml\"}
#golang = {version=\"1.19.5\", foo=\"bar\"}

[plugins]
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#df03b6719dd465d565bb66273942c8495673eaa4\"
tiny-ref = \"https://github.com/rtx-plugins/rtx-tiny#c532b140abd4ca00d3e76651b9bd32a980bd483c\"
"

export RTX_DEFAULT_CONFIG_FILENAME=.MISSING
Expand Down
19 changes: 4 additions & 15 deletions e2e/test_nodejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,29 @@ set -euo pipefail
source "$(dirname "$0")/assert.sh"

export RTX_EXPERIMENTAL=1
export RTX_NODE_BUILD=1
export RTX_NODE_COREPACK=1
export RTX_NODE_DEFAULT_PACKAGES_FILE="$ROOT/e2e/.default-npm-packages"

rtx plugin uninstall node
rtx i node node@lts/hydrogen
assert_contains "rtx x node@lts/hydrogen -- node --version" "v18."
assert "rtx x -- node --version" "v20.0.0"
assert_contains "rtx node node-build --version" "node-build "
assert_contains "rtx x -- which yarn" "yarn"

# test asdf-nodejs
rtx plugin i nodejs https://github.com/asdf-vm/asdf-nodejs.git
rtx use [email protected]
rtx ls
assert "rtx x -- node --version" "v20.1.0"
assert_contains "rtx ls-remote nodejs" "20.1.0"
assert_contains "rtx node nodebuild --version" "node-build "
rtx use --rm node

# RTX_LEGACY_VERSION_FILE env var
RTX_LEGACY_VERSION_FILE=1 assert_contains "rtx current node" "20.0.0"
RTX_LEGACY_VERSION_FILE=0 assert_not_contains "rtx current node" "20.0.0"
rtx plugin uninstall nodejs
assert_not_contains "rtx plugins --user" "node"

# disable nodejs plugin
RTX_DISABLE_TOOLS=node assert_not_contains "rtx plugins --core" "node"

export RTX_NODE_BUILD=0
rtx uninstall -a node
rtx i node
assert "rtx x -- node --version" "v20.0.0"
# rtx uninstall node
# RTX_NODE_COMPILE=1 rtx i node
# assert "rtx x -- node --version" "v20.0.0"

export RTX_NODE_COREPACK=1
rtx uninstall node
rtx i node
assert_contains "rtx x node -- which yarn" "yarn"
1 change: 1 addition & 0 deletions e2e/test_plugins_install
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ rtx plugin uninstall tiny

rtx plugin update
rtx plugin update shfmt
rtx i
9 changes: 9 additions & 0 deletions e2e/test_poetry
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ set -euo pipefail
# shellcheck source-path=SCRIPTDIR
source "$(dirname "$0")/assert.sh"

if [ "${TEST_ALL:-}" != 1 ]; then
exit
fi

rm -rf "$RTX_DATA_DIR/cache/poetry"

export POETRY_HOME=".poetry"

eval "$(rtx activate bash)"
cat >.e2e.rtx.toml <<EOF
[tools]
python = "3.12.0"
poetry = {version="1.7.1", pyproject="pyproject.toml"}
EOF
rtx i python && _rtx_hook
rtx i poetry && _rtx_hook

Expand Down
4 changes: 4 additions & 0 deletions e2e/test_python
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ set -euo pipefail
# shellcheck source-path=SCRIPTDIR
source "$(dirname "$0")/assert.sh"

if [ "${TEST_ALL:-}" != 1 ]; then
exit
fi

export RTX_EXPERIMENTAL=1
export RTX_PYTHON_DEFAULT_PACKAGES_FILE="$ROOT/e2e/.default-python-packages"

Expand Down
15 changes: 12 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,36 @@ test-e2e TEST=("all"): build
# run unit tests w/ coverage
test-coverage:
#!/usr/bin/env bash
echo "::group::Setup"
set -euxo pipefail
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace

if [[ -n "${RTX_GITHUB_BOT_TOKEN:-}" ]]; then
export GITHUB_API_TOKEN="$RTX_GITHUB_BOT_TOKEN"
fi

export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$PWD/target}"
export PATH="${CARGO_TARGET_DIR}/debug:$PATH"
cargo test --all-features

echo "::group::Build w/ coverage"
cargo build --all-features
echo "::endgroup::"
./e2e/run_all_tests
if [[ "${TEST_TRANCHE:-}" == 0 ]]; then
echo "::group::Unit tests"
cargo test --all-features
echo "::group::Trust"
rtx trust
echo "::group::render-help render-completions render-mangen"
just render-help render-completions render-mangen
echo "::group::Implode"
rtx implode
elif [[ "${TEST_TRANCHE:-}" == 1 ]]; then
echo "::group::Trust"
rtx trust
echo "::group::Self update"
rtx self-update -fy
fi
echo "::group::Render lcov report"
cargo llvm-cov report --lcov --output-path lcov.info

# delete built files
Expand Down
9 changes: 8 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail

echo "::group::Setup"
git config --global user.name rtx-vm
git config --global user.email [email protected]

Expand All @@ -11,6 +12,7 @@ export BASE_DIR RTX_VERSION RELEASE_DIR
rm -rf "${RELEASE_DIR:?}/$RTX_VERSION"
mkdir -p "$RELEASE_DIR/$RTX_VERSION"

echo "::group::Build"
find artifacts -name 'tarball-*' -exec sh -c '
target=${1#artifacts/tarball-}
cp "artifacts/tarball-$target/"*.tar.gz "$RELEASE_DIR/$RTX_VERSION"
Expand All @@ -37,6 +39,7 @@ for platform in "${platforms[@]}"; do
cp -v rtx/bin/rtx "$RELEASE_DIR/$RTX_VERSION/rtx-$RTX_VERSION-$platform"
done

echo "::group::Checksums"
pushd "$RELEASE_DIR"
echo "$RTX_VERSION" | tr -d 'v' >VERSION
cp rtx-latest-linux-x64 rtx-latest-linux-amd64
Expand All @@ -54,18 +57,22 @@ gpg --clearsign -u 408B88DB29DDE9E0 <SHASUMS256.txt >SHASUMS256.asc
gpg --clearsign -u 408B88DB29DDE9E0 <SHASUMS512.txt >SHASUMS512.asc
popd

echo "::group::install.sh"
./rtx/scripts/render-install.sh >"$RELEASE_DIR"/install.sh
chmod +x "$RELEASE_DIR"/install.sh
shellcheck "$RELEASE_DIR"/install.sh
gpg -u 408B88DB29DDE9E0 --output "$RELEASE_DIR"/install.sh.sig --sign "$RELEASE_DIR"/install.sh

if [[ "$DRY_RUN" != 1 ]]; then
echo "::group::Publish npm @jdxcode/rtx"
NPM_PREFIX=@jdxcode/rtx ./rtx/scripts/release-npm.sh
echo "::group::Publish npm rtx-cli"
NPM_PREFIX=rtx-cli ./rtx/scripts/release-npm.sh
#AWS_S3_BUCKET=rtx.jdx.dev ./rtx/scripts/publish-s3.sh
echo "::group::Publish r2"
./rtx/scripts/publish-r2.sh
fi

echo "::group::Publish homebrew"
./rtx/scripts/render-homebrew.sh >homebrew-tap/rtx.rb
pushd homebrew-tap
git add . && git commit -m "rtx ${RTX_VERSION#v}"
Expand Down
6 changes: 1 addition & 5 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ impl Install {

fn install_missing_runtimes(&self, config: &Config) -> Result<()> {
let mut ts = ToolsetBuilder::new().with_latest_versions().build(config)?;
let versions = ts
.list_missing_versions(config)
.into_iter()
.cloned()
.collect::<Vec<_>>();
let versions = ts.list_missing_versions();
if versions.is_empty() {
info!("all runtimes are installed");
return Ok(());
Expand Down
Loading
Loading