Skip to content

Commit

Permalink
Download langs CLI in system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Heliozoa committed Jul 12, 2023
1 parent e22906b commit 528553f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
14 changes: 14 additions & 0 deletions bin/.common
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ function point_docker_cli_to_minikube_docker() {
eval "$(minikube -p minikube docker-env --shell bash)"
echo ""
}

function ensure_tmc_langs_cli_downloaded() {
path_to_tmc=$(relativize_path "../services/tmc")
path_to_tmc_version="$path_to_tmc"/tmc-langs-version
tmc_version=$(< "$path_to_tmc_version" tr -d '[:space:]')
if [ -f "$path_to_tmc"/tmc-langs-cli-x86_64-unknown-linux-gnu-"$tmc_version" ];
then
echo "Found tmc-langs-cli"
else
echo "Downloading tmc-langs-cli"
path_to_downloader=$(relativize_path "./download-tmc-langs")
run_command "$path_to_downloader"
fi
}
1 change: 1 addition & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ensure_program_in_path "minikube"
ensure_program_in_path "kustomize"
check_minikube_version
ensure_common_programs_in_path
ensure_tmc_langs_cli_downloaded

run_command npm run postinstall
echo ""
Expand Down
2 changes: 1 addition & 1 deletion services/tmc/src/tmc/cli.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://raw.githubusercontent.com/rage/tmc-langs-rust/0.31.2/crates/tmc-langs-cli/bindings.d.ts
// https://raw.githubusercontent.com/rage/tmc-langs-rust/0.32.0/crates/tmc-langs-cli/bindings.d.ts

export type Locale = string

Expand Down
3 changes: 3 additions & 0 deletions services/tmc/src/tmc/cli.guard.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

/*
* Generated type guards for "cli.d.ts".
* WARNING: Do not manually change this file.
Expand Down
22 changes: 22 additions & 0 deletions system-tests/src/setup/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import systemTestsPackageLockJson from "../../package-lock.json"
async function globalSetup(config: FullConfig): Promise<void> {
await makeSureNecessaryProgramsAreInstalled(config)
await makeSureNpmCiHasBeenRan()
await downloadTmcLangsCli()
await setupSystemTestDb()
// After this global.setup.spec.ts is ran
}
Expand All @@ -35,6 +36,27 @@ async function makeSureNpmCiHasBeenRan() {
}
}

// Download the langs CLI binary for the TMC exercise service to work.
async function downloadTmcLangsCli() {
try {
console.time("download-tmc-langs")
const downloadTmcLangsPath = path.join(__dirname, "../../../bin/download-tmc-langs")
console.log("Downloading langs CLI.")
const res = spawnSync(downloadTmcLangsPath, { stdio: "inherit" })
if (res.status != 0) {
console.error("Error: Could not download langs CLI.")
if (res.error) {
throw res.error
} else {
throw new Error(`Downloading langs CLI returned non-zero status code ${res.status}`)
}
}
console.log("Successfully downloaded langs CLI.")
} finally {
console.timeEnd("download-tmc-langs")
}
}

// The setup system test db called by playwright to make the playwright vscode extension to work.
async function setupSystemTestDb() {
try {
Expand Down

0 comments on commit 528553f

Please sign in to comment.