From 934039bd13b89f62873aa5d193d074f5a92341d3 Mon Sep 17 00:00:00 2001 From: Emma Casolin Date: Wed, 6 Jul 2022 13:51:39 +1000 Subject: [PATCH] ci: chocolatey caching Optimised Windows CI/CD setup by internalising and caching chocolatey packages Fixes #397 --- .gitlab-ci.yml | 149 +++++++-------- package-lock.json | 1 - package.json | 1 - scripts/build-platforms-generate.sh | 180 ++++++++++++++++++ scripts/build:platforms-generate.sh | 174 ----------------- ...est-generate.sh => check-test-generate.sh} | 5 +- scripts/choco-install.ps1 | 38 ++++ tests/bin/bootstrap.test.ts | 4 +- 8 files changed, 296 insertions(+), 256 deletions(-) create mode 100755 scripts/build-platforms-generate.sh delete mode 100755 scripts/build:platforms-generate.sh rename scripts/{check:test-generate.sh => check-test-generate.sh} (93%) create mode 100644 scripts/choco-install.ps1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b8a59bfd5..472dc93adf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,6 +30,8 @@ cache: - ./tmp/ts-node-cache/ # Homebrew cache is only used by the macos runner - ./tmp/Homebrew + # Chocolatey cache is only used by the windows runner + - ./tmp/chocolatey/ # `jest` cache is configured in jest.config.js - ./tmp/jest/ @@ -41,74 +43,71 @@ stages: image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner -# check:lint: -# stage: check -# needs: [] -# script: -# - > -# nix-shell --run ' -# npm run lint; -# ' -# rules: -# # Runs on feature and staging commits and ignores version commits -# - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Runs on tag pipeline where the tag is a prerelease or release version -# - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Manually run on commits other than master and ignore version commits -# - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# when: manual +check:lint: + stage: check + needs: [] + script: + - > + nix-shell --run ' + npm run lint; + ' + rules: + # Runs on feature and staging commits and ignores version commits + - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Runs on tag pipeline where the tag is a prerelease or release version + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Manually run on commits other than master and ignore version commits + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + when: manual -# check:nix-dry: -# stage: check -# needs: [] -# script: -# - nix-build -v -v --dry-run ./release.nix -# rules: -# # Runs on feature and staging commits and ignores version commits -# - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Runs on tag pipeline where the tag is a prerelease or release version -# - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Manually run on commits other than master and ignore version commits -# - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# when: manual +check:nix-dry: + stage: check + needs: [] + script: + - nix-build -v -v --dry-run ./release.nix + rules: + # Runs on feature and staging commits and ignores version commits + - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Runs on tag pipeline where the tag is a prerelease or release version + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Manually run on commits other than master and ignore version commits + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + when: manual -# check:test-generate: -# stage: check -# needs: [] -# script: -# - mkdir -p ./tmp -# - > -# nix-shell --run ' -# ./scripts/check:test-generate.sh > ./tmp/check:test.yml -# ' -# artifacts: -# when: always -# paths: -# - ./tmp/check:test.yml -# rules: -# # Runs on staging commits and ignores version commits -# - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Manually run on commits other than master and staging and ignore version commits -# - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# when: manual +check:test-generate: + stage: check + needs: [] + script: + - mkdir -p ./tmp + - ./scripts/check-test-generate.sh > ./tmp/check-test.yml + artifacts: + when: always + paths: + - ./tmp/check-test.yml + rules: + # Runs on staging commits and ignores version commits + - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Manually run on commits other than master and staging and ignore version commits + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + when: manual -# check:test: -# stage: check -# needs: -# - check:test-generate -# inherit: -# variables: false -# trigger: -# include: -# - artifact: tmp/check:test.yml -# job: check:test-generate -# strategy: depend -# rules: -# # Runs on staging commits and ignores version commits -# - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# # Manually run on commits other than master and staging and ignore version commits -# - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ -# when: manual +check:test: + stage: check + needs: + - check:test-generate + inherit: + variables: false + trigger: + include: + - artifact: tmp/check-test.yml + job: check:test-generate + strategy: depend + rules: + # Runs on staging commits and ignores version commits + - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Manually run on commits other than master and staging and ignore version commits + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + when: manual build:merge: stage: build @@ -143,17 +142,16 @@ build:platforms-generate: needs: [] script: - mkdir -p ./tmp - - ./scripts/build:platforms-generate.sh > ./tmp/build:platforms.yml + - ./scripts/build-platforms-generate.sh > ./tmp/build-platforms.yml artifacts: when: always paths: - - ./tmp/build:platforms.yml + - ./tmp/build-platforms.yml rules: # Runs on staging commits and ignores version commits - - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ - # Manually run on commits other than master and staging and ignore version commits - - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ - when: manual + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Runs on tag pipeline where the tag is a prerelease or release version + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ build:platforms: stage: build @@ -163,15 +161,14 @@ build:platforms: variables: false trigger: include: - - artifact: tmp/build:platforms.yml + - artifact: tmp/build-platforms.yml job: build:platforms-generate strategy: depend rules: # Runs on staging commits and ignores version commits - - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ - # Manually run on commits other than master and staging and ignore version commits - - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ - when: manual + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + # Runs on tag pipeline where the tag is a prerelease or release version + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ build:dist: stage: build diff --git a/package-lock.json b/package-lock.json index 0d042805b0..fb1cb22175 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,6 @@ "google-protobuf": "^3.14.0", "ip-num": "^1.3.3-0", "isomorphic-git": "^1.8.1", - "jest-junit": "^13.2.0", "jose": "^4.3.6", "lexicographic-integer": "^1.1.0", "multiformats": "^9.4.8", diff --git a/package.json b/package.json index c416be6aae..60a683df3e 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,6 @@ "google-protobuf": "^3.14.0", "ip-num": "^1.3.3-0", "isomorphic-git": "^1.8.1", - "jest-junit": "^13.2.0", "jose": "^4.3.6", "lexicographic-integer": "^1.1.0", "multiformats": "^9.4.8", diff --git a/scripts/build-platforms-generate.sh b/scripts/build-platforms-generate.sh new file mode 100755 index 0000000000..0a1833f0f8 --- /dev/null +++ b/scripts/build-platforms-generate.sh @@ -0,0 +1,180 @@ +#!/usr/bin/env bash + +shopt -s globstar +shopt -s nullglob + +# Quote the heredoc to prevent shell expansion +cat << "EOF" +default: + interruptible: true + +variables: + GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}" + GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git" + GIT_SUBMODULE_STRATEGY: "recursive" + # Cache .npm + NPM_CONFIG_CACHE: "./tmp/npm" + # Prefer offline node module installation + NPM_CONFIG_PREFER_OFFLINE: "true" + # `ts-node` has its own cache + # It must use an absolute path, otherwise ts-node calls will CWD + TS_CACHED_TRANSPILE_CACHE: "${CI_PROJECT_DIR}/tmp/ts-node-cache" + TS_CACHED_TRANSPILE_PORTABLE: "true" + # Homebrew cache only used by macos runner + HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew" + +# Cached directories shared between jobs & pipelines per-branch per-runner +cache: + key: $CI_COMMIT_REF_SLUG + when: 'always' + paths: + - ./tmp/npm/ + - ./tmp/ts-node-cache/ + # Homebrew cache is only used by the macos runner + - ./tmp/Homebrew + # Chocolatey cache is only used by the windows runner + - ./tmp/chocolatey/ + # `jest` cache is configured in jest.config.js + - ./tmp/jest/ + +stages: + - build # Cross-platform library compilation, unit tests + +image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner +EOF + +printf "\n" + +# Each test directory has its own job +for test_dir in tests/**/*/; do + test_files=("$test_dir"*.test.ts) + if [ ${#test_files[@]} -eq 0 ]; then + continue + fi + # Remove trailing slash + test_dir="${test_dir%\/}" + # Remove `tests/` prefix + test_dir="${test_dir#*/}" + cat << EOF +build:linux $test_dir: + stage: build + needs: [] + script: + - > + nix-shell --run ' + npm test -- --ci --coverage --runInBand ${test_files[@]}; + ' + artifacts: + when: always + reports: + junit: + - ./tmp/junit/junit.xml + coverage_report: + coverage_format: cobertura + path: ./tmp/coverage/cobertura-coverage.xml + coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' +EOF + printf "\n" +done + +# All top-level test files are accumulated into 1 job +test_files=(tests/*.test.ts) +cat << EOF +build:linux index: + stage: build + needs: [] + script: + - > + nix-shell --run ' + npm test -- --ci --coverage --runInBand ${test_files[@]}; + ' + artifacts: + when: always + reports: + junit: + - ./tmp/junit/junit.xml + coverage_report: + coverage_format: cobertura + path: ./tmp/coverage/cobertura-coverage.xml + coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' +EOF + +printf "\n" + +# Using shards to optimise tests +# In the future we can incorporate test durations rather than using +# a static value for the parallel keyword + +# Number of parallel shards to split the test suite into +CI_PARALLEL=2 + +cat << "EOF" +build:windows: + stage: build + needs: [] +EOF +cat << EOF + parallel: $CI_PARALLEL +EOF +cat << "EOF" + tags: + - windows + before_script: + - .\scripts\choco-install.ps1 + - refreshenv + script: + - npm config set msvs_version 2019 + - npm install --ignore-scripts + - $env:Path = "$(npm bin);" + $env:Path + - npm test -- --ci --coverage --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL --maxWorkers=50% + artifacts: + when: always + reports: + junit: + - ./tmp/junit/junit.xml + coverage_report: + coverage_format: cobertura + path: ./tmp/coverage/cobertura-coverage.xml + coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' +EOF + +printf "\n" + +cat << "EOF" +build:macos: + stage: build + needs: [] +EOF +cat << EOF + parallel: $CI_PARALLEL +EOF +cat << "EOF" + tags: + - shared-macos-amd64 + image: macos-11-xcode-12 + variables: + HOMEBREW_NO_INSTALL_UPGRADE: "true" + HOMEBREW_NO_INSTALL_CLEANUP: "true" + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "true" + HOMEBREW_NO_AUTO_UPDATE: "true" + before_script: + - eval "$(brew shellenv)" + - brew install node@16 + - brew link --overwrite node@16 + - hash -r + script: + - npm install --ignore-scripts + - export PATH="$(npm bin):$PATH" + - npm test -- --ci --coverage --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL --maxWorkers=50% + artifacts: + when: always + reports: + junit: + - ./tmp/junit/junit.xml + coverage_report: + coverage_format: cobertura + path: ./tmp/coverage/cobertura-coverage.xml + coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' +EOF + +printf "\n" diff --git a/scripts/build:platforms-generate.sh b/scripts/build:platforms-generate.sh deleted file mode 100755 index 4e8dde2016..0000000000 --- a/scripts/build:platforms-generate.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env bash - -shopt -s globstar -shopt -s nullglob - -# Quote the heredoc to prevent shell expansion -cat << "EOF" -default: - interruptible: true - -variables: - GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}" - GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git" - GIT_SUBMODULE_STRATEGY: "recursive" - # Cache .npm - NPM_CONFIG_CACHE: "./tmp/npm" - # Prefer offline node module installation - NPM_CONFIG_PREFER_OFFLINE: "true" - # `ts-node` has its own cache - # It must use an absolute path, otherwise ts-node calls will CWD - TS_CACHED_TRANSPILE_CACHE: "${CI_PROJECT_DIR}/tmp/ts-node-cache" - TS_CACHED_TRANSPILE_PORTABLE: "true" - # Homebrew cache only used by macos runner - HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew" - -# Cached directories shared between jobs & pipelines per-branch per-runner -cache: - key: $CI_COMMIT_REF_SLUG - when: 'always' - paths: - - ./tmp/npm/ - - ./tmp/ts-node-cache/ - # Homebrew cache is only used by the macos runner - - ./tmp/Homebrew - # `jest` cache is configured in jest.config.js - - ./tmp/jest/ - -stages: - - build # Cross-platform library compilation, unit tests - -image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner -EOF - -printf "\n" - -# # Each test directory has its own job -# for test_dir in tests/**/*/; do -# test_files=("$test_dir"*.test.ts) -# if [ ${#test_files[@]} -eq 0 ]; then -# continue -# fi -# # Remove trailing slash -# test_dir="${test_dir%\/}" -# # Remove `tests/` prefix -# test_dir="${test_dir#*/}" -# cat << EOF -# build:linux $test_dir: -# stage: build -# needs: [] -# script: -# - > -# nix-shell --run ' -# npm test -- --ci --coverage ${test_files[@]}; -# ' -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit/junit.xml -# coverage_report: -# coverage_format: cobertura -# path: ./tmp/coverage/cobertura-coverage.xml -# coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' -# EOF -# printf "\n" -# done - -# # All top-level test files are accumulated into 1 job -# test_files=(tests/*.test.ts) -# cat << EOF -# build:linux index: -# stage: build -# needs: [] -# script: -# - > -# nix-shell --run ' -# npm test -- --ci --coverage ${test_files[@]}; -# ' -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit/junit.xml -# coverage_report: -# coverage_format: cobertura -# path: ./tmp/coverage/cobertura-coverage.xml -# coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' -# EOF - -# printf "\n" - -# Using shards to optimise tests -# In the future we can incorporate test durations rather than using -# a static value for the parallel keyword - -# Number of parallel shards to split the test suite into -CI_PARALLEL=2 - -# cat << "EOF" -# build:windows: -# stage: build -# needs: [] -# EOF -# cat << EOF -# parallel: $CI_PARALLEL -# EOF -# cat << "EOF" -# tags: -# - windows -# before_script: -# - choco install nodejs --version=16.14.2 -y -# - refreshenv -# script: -# - npm config set msvs_version 2019 -# - npm install --ignore-scripts -# - $env:Path = "$(npm bin);" + $env:Path -# - npm test -- --ci --coverage --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit/junit.xml -# coverage_report: -# coverage_format: cobertura -# path: ./tmp/coverage/cobertura-coverage.xml -# coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' -# EOF - -# printf "\n" - -cat << "EOF" -build:macos: - stage: build - needs: [] -EOF -cat << EOF - parallel: $CI_PARALLEL -EOF -cat << "EOF" - tags: - - shared-macos-amd64 - image: macos-11-xcode-12 - variables: - HOMEBREW_NO_INSTALL_UPGRADE: "true" - HOMEBREW_NO_INSTALL_CLEANUP: "true" - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "true" - HOMEBREW_NO_AUTO_UPDATE: "true" - before_script: - - eval "$(brew shellenv)" - - brew install node@16 - - brew link --overwrite node@16 - - hash -r - script: - - npm install --ignore-scripts - - export PATH="$(npm bin):$PATH" - - npm test -- --ci --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL --maxWorkers=50% - artifacts: - when: always - reports: - junit: - - ./tmp/junit/junit.xml -EOF - -printf "\n" diff --git a/scripts/check:test-generate.sh b/scripts/check-test-generate.sh similarity index 93% rename from scripts/check:test-generate.sh rename to scripts/check-test-generate.sh index aae9a74bba..d9b8e59a66 100755 --- a/scripts/check:test-generate.sh +++ b/scripts/check-test-generate.sh @@ -24,6 +24,7 @@ variables: # Cached directories shared between jobs & pipelines per-branch per-runner cache: key: $CI_COMMIT_REF_SLUG + when: 'always' paths: - ./tmp/npm/ - ./tmp/ts-node-cache/ @@ -55,7 +56,7 @@ check:test $test_dir: script: - > nix-shell --run ' - npm test -- --ci --coverage ${test_files[@]}; + npm test -- --ci --coverage --runInBand ${test_files[@]}; ' artifacts: when: always @@ -79,7 +80,7 @@ check:test index: script: - > nix-shell --run ' - npm test -- --ci --coverage ${test_files[@]}; + npm test -- --ci --coverage --runInBand ${test_files[@]}; ' artifacts: when: always diff --git a/scripts/choco-install.ps1 b/scripts/choco-install.ps1 new file mode 100644 index 0000000000..222a126097 --- /dev/null +++ b/scripts/choco-install.ps1 @@ -0,0 +1,38 @@ +$nodejs = "nodejs.install" +$python = "python3" + +# Check for existence of required environment variables +if ( $env:ChocolateyInstall -eq $null ) { + [Console]::Error.WriteLine('Missing $env:ChocolateyInstall environment variable') + exit 1 +} + +# Add the cached packages with source priority 1 (Chocolatey community is 0) +New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey" -ItemType "directory" -ErrorAction:SilentlyContinue +choco source add --name="cache" --source="${PSScriptRoot}\..\tmp\chocolatey" --priority=1 + +# Install nodejs v16.14.2 (will use cache if exists) +choco install "$nodejs" --version="16.14.2" --require-checksums -y +# Internalise nodejs to cache if doesn't exist +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs\$nodejs.16.14.2.nupkg" -PathType Leaf) ) { + Rename-Item -Path "$env:ChocolateyInstall\lib\$nodejs\$nodejs.nupkg" -NewName "$nodejs.nupkg.zip" -ErrorAction:SilentlyContinue + Expand-Archive -LiteralPath "$env:ChocolateyInstall\lib\$nodejs\$nodejs.nupkg.zip" -DestinationPath "$env:ChocolateyInstall\lib\$nodejs" -Force + Remove-Item "$env:ChocolateyInstall\lib\$nodejs\_rels" -Recurse + Remove-Item "$env:ChocolateyInstall\lib\$nodejs\package" -Recurse + Remove-Item "$env:ChocolateyInstall\lib\$nodejs\[Content_Types].xml" + New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs" -ItemType "directory" -ErrorAction:SilentlyContinue + choco pack "$env:ChocolateyInstall\lib\$nodejs\$nodejs.nuspec" --outdir "${PSScriptRoot}\..\tmp\chocolatey\$nodejs" +} + +# Install python v3.9.12 (will use cache if exists) +choco install $python --version="3.9.12" --require-checksums -y +# Internalise python to cache if doesn't exist +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$python\$python.3.9.12.nupkg" -PathType Leaf) ) { + Rename-Item -Path "$env:ChocolateyInstall\lib\$python\$python.nupkg" -NewName "$python.nupkg.zip" -ErrorAction:SilentlyContinue + Expand-Archive -LiteralPath "$env:ChocolateyInstall\lib\$python\$python.nupkg.zip" -DestinationPath "$env:ChocolateyInstall\lib\$python" -Force + Remove-Item "$env:ChocolateyInstall\lib\$python\_rels" -Recurse + Remove-Item "$env:ChocolateyInstall\lib\$python\package" -Recurse + Remove-Item "$env:ChocolateyInstall\lib\$python\[Content_Types].xml" + New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey\$python" -ItemType "directory" -ErrorAction:SilentlyContinue + choco pack "$env:ChocolateyInstall\lib\$python\$python.nuspec" --outdir "${PSScriptRoot}\..\tmp\chocolatey\$python" +} diff --git a/tests/bin/bootstrap.test.ts b/tests/bin/bootstrap.test.ts index 75d9a77c53..dab8ce5b5e 100644 --- a/tests/bin/bootstrap.test.ts +++ b/tests/bin/bootstrap.test.ts @@ -219,8 +219,8 @@ describe('bootstrap', () => { }); }); await new Promise((res) => { - bootstrapProcess1.once('exit', () => res(null)) - }) + bootstrapProcess1.once('exit', () => res(null)); + }); // Attempting to bootstrap should fail with existing state const bootstrapProcess2 = await testBinUtils.pkStdio( [