Skip to content
Snippets Groups Projects
Unverified Commit e583d26f authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: check scripts/prepare-dev-env.sh script

parent aec0ee06
No related branches found
No related tags found
No related merge requests found
Pipeline #13654216 passed
Loading
Loading
@@ -6,3 +6,4 @@ golang 1.17.6 # datasource=github-releases depName=golang/go
shellcheck 0.8.0 # datasource=github-releases depName=koalaman/shellcheck
shfmt 3.4.3 # datasource=github-releases depName=mvdan/sh
pre-commit 2.18.0 # datasource=github-releases depName=pre-commit/pre-commit
python system # use the system python
Loading
Loading
@@ -9,6 +9,7 @@ Setup process:
 
1. Ensure that the file [`scripts/install-asdf-plugins.sh`](https://gitlab.com/gitlab-com/runbooks/-/blob/master/scripts/install-asdf-plugins.sh) exists in the repository. Tailor for the `asdf` configuration of the project.
1. Ensure that the files [`scripts/update-asdf-version-variables.sh`](https://gitlab.com/gitlab-com/runbooks/-/blob/master/scripts/update-asdf-version-variables.sh) exists in the repository.
1. The optional file `scripts/prepare-dev-env.sh` will be executed after `scripts/install-asdf-plugins.sh` has run, if it exists. This file should contain any development configuration setup steps needed to prepare a development environment.
1. If the job will need SSH access to GitLab using a [deploy key](https://docs.gitlab.com/ee/user/project/deploy_keys/), create the deploy key for the project to which access will be required. Add the private key to the `VALIDATE_ASDF_TOOL_VERSIONS_DEPLOY_KEY_FILE` CI/CD variable.
1. Note that the SSH Agent may fail to parse the private key if a final newline is omitted.
1. To generate the key, follow the instructions at <https://docs.gitlab.com/ee/user/ssh.html#generate-an-ssh-key-pair>.
Loading
Loading
Loading
Loading
@@ -21,6 +21,7 @@ validate_asdf_tool_versions:
- ./scripts/install-asdf-plugins.sh
- ./scripts/update-asdf-version-variables.sh
- git diff --exit-code
- if [[ scripts/prepare-dev-env.sh ]]; then scripts/prepare-dev-env.sh || { echo "Running scripts/prepare-dev-env.sh failed."; exit 1; }; fi
rules:
# This script can be quite slow (mostly due to the ruby install)
# so we only run it when there have been changes
Loading
Loading
@@ -32,6 +33,7 @@ validate_asdf_tool_versions:
- .tool-versions
- .ruby-version
- .gitlab-ci-asdf-versions.yml
- scripts/prepare-dev-env.sh
 
# Automatically retry on any system blips
retry:
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ brew install asdf
 
Linux users should follow the instructions for their package manager in [the ASDF documentation](https://asdf-vm.com/guide/getting-started).
 
### Step 2: Install development dependencies
### Step 3: Install development dependencies
 
Install all the plugins by running:
 
Loading
Loading
@@ -45,6 +45,16 @@ This will install required `asdf` plugins, and install the correct versions of t
 
Note that after pulling changes to the repository, you may sometimes need to re-run `./scripts/install-asdf-plugins.sh` to update your locally installed plugins and tool-versions.
 
### Step 4: (Optional) Prepare Your Development Environment
If the `scripts/prepare-dev-env.sh` environment exists for the project, run it.
```shell
./scripts/prepare-dev-env.sh
```
This will setup any local configuration that may be required, such as installing `pre-commit` hooks, allowing `direnv` execution etc.
## Updating Tool Versions
 
We use CI checks to ensure that tool versions used in GitLab-CI and on developer instances don't go out of sync.
Loading
Loading
#!/usr/bin/env bash
set -euo pipefail
# ---------------------------------------------------------
# This script will prepare your development environment
# while working on this project. Run it after cloning this
# project.
#
# It's recommended that you review
# https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/docs/developer-setup.md
# first.
# ---------------------------------------------------------
cd "$(dirname "${BASH_SOURCE[0]}")/.."
warn() {
echo >&2 -e "${1-}"
echo >&2 -e "Recommended reading: https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/docs/developer-setup.md"
}
# check that asdf is installed
[[ -n ${ASDF_DIR:-} ]] || {
warn "asdf not installed. "
exit 1
}
# install asdf dependencies
echo "installing asdf tooling with scripts/install-asdf-plugins.sh..."
./scripts/install-asdf-plugins.sh
echo "performing a reshim"
asdf reshim
asdf current
# pre-commit is optional
if command -v pre-commit &>/dev/null; then
echo "running pre-commit install..."
pre-commit install
pre-commit install-hooks
else
warn "pre-commit is not installed. Skipping."
fi
# direnv is optional
if command -v direnv &>/dev/null; then
echo "running direnv allow"
if [[ -f ".envrc" ]]; then direnv allow; fi
else
warn "direnv is not installed. Skipping."
fi
#!/usr/bin/env bash
 
# See the README.md for details of how this script works
# shellcheck source=/dev/null
source "$ASDF_DIR/asdf.sh"
 
# See the README.md for details of how this script works
set -euo pipefail
IFS=$'\n\t'
 
Loading
Loading
@@ -22,8 +24,10 @@ generate() {
print "variables:"
}
{
gsub("-", "_", $1);
print " GL_ASDF_" toupper($1) "_VERSION: " $2
if ($2 != "system") {
gsub("-", "_", $1);
print " GL_ASDF_" toupper($1) "_VERSION: " $2
}
}
'
}
Loading
Loading
@@ -37,8 +41,10 @@ generate_defaults() {
print "variables:"
}
{
gsub("-", "_", $1);
print " GL_COMMON_CI_TASKS_DEFAULT_ASDF_" toupper($1) "_VERSION: " $2
if ($2 != "system") {
gsub("-", "_", $1);
print " GL_COMMON_CI_TASKS_DEFAULT_ASDF_" toupper($1) "_VERSION: " $2
}
}
'
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment