mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-28 03:13:03 +01:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f4b39ce87 | ||
|
|
9eccfb3691 |
No files matched your search
@@ -6,6 +6,8 @@ updates:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
labels: []
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
gha-minor:
|
||||
patterns:
|
||||
@@ -19,6 +21,8 @@ updates:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
labels: []
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
py-minor:
|
||||
patterns:
|
||||
@@ -26,3 +30,19 @@ updates:
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
- package-ecosystem: npm
|
||||
directory: "/.github/workflows/installer"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
labels: []
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
npm-minor:
|
||||
patterns:
|
||||
- "*"
|
||||
update-types:
|
||||
- major
|
||||
- minor
|
||||
- patch
|
||||
@@ -0,0 +1,45 @@
|
||||
# Workflow checks
|
||||
|
||||
The `Workflow lint` workflow runs jactionlint on pull requests and pushes to
|
||||
`master`. It checks workflows and Dependabot configuration with the default
|
||||
profile, including ShellCheck for inline shell scripts. It runs without online
|
||||
checks or publishing credentials.
|
||||
|
||||
To run the same checks locally, install jactionlint 2.6.0 and ShellCheck, then run
|
||||
from the repository root:
|
||||
|
||||
```sh
|
||||
jactionlint --profile=default --no-online
|
||||
```
|
||||
|
||||
Keep the local jactionlint version aligned with the pinned action in `lint.yml`.
|
||||
There is no baseline: new findings fail the check. Any rule exception should be
|
||||
limited to the relevant line and explain why it is needed.
|
||||
|
||||
## Project tracking
|
||||
|
||||
`project.yml` intentionally uses `pull_request_target` so the GitHub App can add
|
||||
fork contributions to the project board. It must not check out or execute PR
|
||||
code. Project IDs are validated before passing them through step outputs, and
|
||||
PR-derived plugin/theme names are restricted to letters, digits, dots, underscores
|
||||
and hyphens.
|
||||
|
||||
The App tokens request explicit permissions: project tracking needs organization
|
||||
projects write access and issues/pull requests read access; dependency updates
|
||||
need contents read access and issues/pull requests write access. Dependency pushes
|
||||
use the job's separate `GITHUB_TOKEN` with contents write access.
|
||||
|
||||
## Installer deployment
|
||||
|
||||
The Vercel CLI is pinned in `installer/package.json` and `installer/package-lock.json`.
|
||||
Dependabot checks this dependency weekly, with a seven-day cooldown for version
|
||||
updates, like the other configured ecosystems. Deployment installs the lockfile
|
||||
with `npm ci --ignore-scripts`; `.vercelignore` uploads only `install.sh`.
|
||||
|
||||
After changing the CLI version, update its lockfile and verify the CLI locally:
|
||||
|
||||
```sh
|
||||
npm install --package-lock-only --ignore-scripts --prefix .github/workflows/installer
|
||||
npm ci --ignore-scripts --prefix .github/workflows/installer
|
||||
.github/workflows/installer/node_modules/.bin/vercel --version
|
||||
```
|
||||
@@ -11,6 +11,7 @@ jobs:
|
||||
check:
|
||||
name: Check for updates
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
permissions:
|
||||
contents: write # this is needed to push commits and branches
|
||||
@@ -30,6 +31,9 @@ jobs:
|
||||
with:
|
||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
permission-contents: read
|
||||
permission-issues: write
|
||||
permission-pull-requests: write
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
|
||||
@@ -19,6 +19,7 @@ jobs:
|
||||
name: Test installer
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
@@ -42,6 +43,7 @@ jobs:
|
||||
name: Deploy installer in install.ohmyz.sh
|
||||
if: github.ref == 'refs/heads/master'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
environment: vercel
|
||||
needs:
|
||||
- test
|
||||
@@ -53,8 +55,16 @@ jobs:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "24"
|
||||
package-manager-cache: false
|
||||
- name: Install Vercel CLI
|
||||
run: npm install -g vercel
|
||||
working-directory: .github/workflows/installer
|
||||
run: npm ci --ignore-scripts --no-audit --no-fund
|
||||
- name: Setup project and deploy
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
@@ -63,4 +73,4 @@ jobs:
|
||||
run: |
|
||||
cp tools/install.sh .github/workflows/installer/install.sh
|
||||
cd .github/workflows/installer
|
||||
vc deploy --prod -t "$VERCEL_TOKEN"
|
||||
./node_modules/.bin/vercel deploy --prod -t "$VERCEL_TOKEN"
|
||||
@@ -1 +1,2 @@
|
||||
install.sh
|
||||
node_modules/
|
||||
+5585
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "ohmyzsh-installer-deploy",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"vercel": "66.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
name: Workflow lint
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
jactionlint:
|
||||
name: Lint GitHub Actions
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Lint workflows and Dependabot configuration
|
||||
uses: jdx/jactionlint@72c00452809bcca05b8bc12acdcf15dd7a9c1c5e # v2.6.0
|
||||
with:
|
||||
profile: default
|
||||
online: "false"
|
||||
@@ -21,6 +21,7 @@ jobs:
|
||||
tests:
|
||||
name: Run tests
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
|
||||
@@ -2,6 +2,8 @@ name: Project tracking
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened]
|
||||
# Board updates need an App token for fork PRs; no PR code is checked out or run.
|
||||
# jactionlint ignore=dangerous-triggers
|
||||
pull_request_target:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
@@ -14,6 +16,10 @@ jobs:
|
||||
add-to-project:
|
||||
name: Add to project
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
@@ -26,13 +32,19 @@ jobs:
|
||||
with:
|
||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
permission-organization-projects: write
|
||||
permission-issues: read
|
||||
permission-pull-requests: read
|
||||
- name: Read project data
|
||||
id: project
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
ORGANIZATION: ohmyzsh
|
||||
PROJECT_NUMBER: "1"
|
||||
run: |
|
||||
# Get Project data
|
||||
# GraphQL variables must reach GitHub literally.
|
||||
# shellcheck disable=SC2016
|
||||
gh api graphql -f query='
|
||||
query($org: String!, $number: Int!) {
|
||||
organization(login: $org){
|
||||
@@ -48,19 +60,29 @@ jobs:
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
|
||||
}' -f org="$ORGANIZATION" -F number="$PROJECT_NUMBER" > project_data.json
|
||||
|
||||
# Parse project data
|
||||
cat >> "$GITHUB_ENV" <<EOF
|
||||
PROJECT_ID=$(jq '.data.organization.projectV2.id' project_data.json)
|
||||
PLUGIN_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
|
||||
THEME_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
|
||||
EOF
|
||||
PROJECT_ID=$(jq -er '.data.organization.projectV2.id' project_data.json)
|
||||
PLUGIN_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
|
||||
THEME_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
|
||||
for id in "$PROJECT_ID" "$PLUGIN_FIELD_ID" "$THEME_FIELD_ID"; do
|
||||
[[ "$id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
|
||||
done
|
||||
{
|
||||
echo "PROJECT_ID=$PROJECT_ID"
|
||||
echo "PLUGIN_FIELD_ID=$PLUGIN_FIELD_ID"
|
||||
echo "THEME_FIELD_ID=$THEME_FIELD_ID"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
- name: Add to project
|
||||
id: item
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
|
||||
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
|
||||
run: |
|
||||
# GraphQL variables must reach GitHub literally.
|
||||
# shellcheck disable=SC2016
|
||||
item_id="$(gh api graphql -f query='
|
||||
mutation($project: ID!, $content: ID!) {
|
||||
addProjectV2ItemById(input: {projectId: $project, contentId: $content}) {
|
||||
@@ -69,10 +91,12 @@ jobs:
|
||||
}
|
||||
}
|
||||
}
|
||||
' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id')"
|
||||
' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id // error("missing project item ID")')"
|
||||
|
||||
echo "ITEM_ID=$item_id" >> $GITHUB_ENV
|
||||
[[ "$item_id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
|
||||
echo "ITEM_ID=$item_id" >> "$GITHUB_OUTPUT"
|
||||
- name: Classify Pull Request
|
||||
id: classify
|
||||
if: github.event_name == 'pull_request_target'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
@@ -109,12 +133,20 @@ jobs:
|
||||
print "THEME=" theme
|
||||
}
|
||||
}
|
||||
' >> "$GITHUB_ENV"
|
||||
' >> "$GITHUB_OUTPUT"
|
||||
- name: Fill Pull Request fields in project
|
||||
if: github.event_name == 'pull_request_target'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
|
||||
ITEM_ID: ${{ steps.item.outputs.ITEM_ID }}
|
||||
PLUGIN_FIELD_ID: ${{ steps.project.outputs.PLUGIN_FIELD_ID }}
|
||||
PLUGIN: ${{ steps.classify.outputs.PLUGIN }}
|
||||
THEME_FIELD_ID: ${{ steps.project.outputs.THEME_FIELD_ID }}
|
||||
THEME: ${{ steps.classify.outputs.THEME }}
|
||||
run: |
|
||||
# GraphQL variables must reach GitHub literally.
|
||||
# shellcheck disable=SC2016
|
||||
gh api graphql -f query='
|
||||
mutation (
|
||||
$project: ID!
|
||||
|
||||
@@ -14,13 +14,18 @@ on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Permissions are granted only to the analysis job.
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
|
||||
@@ -50,16 +50,6 @@ function _omz_nvm_setup_autoload {
|
||||
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
|
||||
|
||||
if [[ -n "$nvmrc_path" ]]; then
|
||||
# Skip version resolution when an exact, unaliased version is already active.
|
||||
local nvmrc_version="$(<"$nvmrc_path")"
|
||||
if [[ "$nvmrc_version" == v<->.<->.<-> \
|
||||
&& ! -e "$NVM_DIR/alias/$nvmrc_version" \
|
||||
&& "${commands[node]-}" == "$NVM_DIR/versions/node/$nvmrc_version/bin/node" \
|
||||
&& -x "${commands[node]-}" ]] \
|
||||
&& (( ! $+functions[node] && ! $+aliases[node] )) \
|
||||
&& [[ "$nvmrc_version" == "$(command node --version 2>/dev/null)" ]]; then
|
||||
return
|
||||
fi
|
||||
local nvmrc_node_version=$(nvm version $(command cat "$nvmrc_path" | tr -dc '[:print:]'))
|
||||
|
||||
if [[ "$nvmrc_node_version" = "N/A" ]]; then
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
emulate -LR zsh
|
||||
|
||||
plugin=${1:-${0:A:h:h}/nvm.plugin.zsh}
|
||||
plugin=${plugin:A}
|
||||
test_dir=$(mktemp -d) || exit 1
|
||||
trap 'command rm -rf -- "$test_dir"' EXIT
|
||||
|
||||
export NVM_DIR="$test_dir/nvm" NVM_TEST_CALLS="$test_dir/calls"
|
||||
mkdir -p "$NVM_DIR/alias" "$test_dir/project/nested" "$test_dir/outside" "$test_dir/system"
|
||||
for version in v1.2.3 v2.0.0; do
|
||||
mkdir -p "$NVM_DIR/versions/node/$version/bin"
|
||||
print -r -- "#!/bin/sh
|
||||
printf '%s\\n' '$version'" > "$NVM_DIR/versions/node/$version/bin/node"
|
||||
chmod +x "$NVM_DIR/versions/node/$version/bin/node"
|
||||
done
|
||||
print -r -- '#!/bin/sh
|
||||
printf "%s\n" v1.2.3' > "$test_dir/system/node"
|
||||
chmod +x "$test_dir/system/node"
|
||||
|
||||
# Record resolver calls, including those made in command substitutions.
|
||||
cat > "$NVM_DIR/nvm.sh" <<'EOF'
|
||||
nvm_find_nvmrc() {
|
||||
local dir=$PWD
|
||||
while [[ $dir != / ]]; do
|
||||
[[ -f $dir/.nvmrc ]] && { print -r -- "$dir/.nvmrc"; return; }
|
||||
dir=${dir:h}
|
||||
done
|
||||
}
|
||||
nvm() {
|
||||
print -r -- "$*" >> "$NVM_TEST_CALLS"
|
||||
local target=${2:-current}
|
||||
case $1 in
|
||||
version)
|
||||
[[ $target == current ]] && { command node --version; return; }
|
||||
[[ -f $NVM_DIR/alias/$target ]] && target=$(<"$NVM_DIR/alias/$target")
|
||||
case $target in
|
||||
default|1|1.2|1.2.3) target=v1.2.3 ;;
|
||||
esac
|
||||
[[ -x $NVM_DIR/versions/node/$target/bin/node ]] && print -r -- "$target" || print N/A
|
||||
;;
|
||||
use)
|
||||
if [[ $target == --silent ]]; then
|
||||
target=$(nvm version "$(<"$(nvm_find_nvmrc)")")
|
||||
else
|
||||
target=$(nvm version "$target")
|
||||
fi
|
||||
path=("$NVM_DIR/versions/node/$target/bin" ${path:#$NVM_DIR/versions/node/*/bin})
|
||||
;;
|
||||
install) return 1 ;;
|
||||
esac
|
||||
}
|
||||
EOF
|
||||
|
||||
path=("$NVM_DIR/versions/node/v1.2.3/bin" $path)
|
||||
builtin cd -q "$test_dir/outside"
|
||||
compdef() { :; }
|
||||
zstyle ':omz:plugins:nvm' autoload yes
|
||||
zstyle ':omz:plugins:nvm' silent-autoload yes
|
||||
source "$plugin"
|
||||
|
||||
typeset -i failures=0 tests=0
|
||||
check() {
|
||||
local description=$1
|
||||
shift
|
||||
(( tests++ ))
|
||||
if "$@"; then
|
||||
print -r -- "PASS: $description"
|
||||
else
|
||||
print -u2 -r -- "FAIL: $description"
|
||||
(( failures++ ))
|
||||
fi
|
||||
}
|
||||
has_call() { [[ "$(<"$NVM_TEST_CALLS")" == *"$1"* ]]; }
|
||||
reset_calls() { : > "$NVM_TEST_CALLS"; }
|
||||
|
||||
print -r -- v1.2.3 > "$test_dir/project/.nvmrc"
|
||||
reset_calls
|
||||
builtin cd "$test_dir/project/nested"
|
||||
check 'matching exact version in parent skips resolver' test ! -s "$NVM_TEST_CALLS"
|
||||
check 'matching version stays selected' test "$(command node --version)" = v1.2.3
|
||||
|
||||
print -r -- v2.0.0 > "$test_dir/project/.nvmrc"
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'editing version file switches runtime' test "$(command node --version)" = v2.0.0
|
||||
check 'switch calls nvm use' has_call 'use --silent'
|
||||
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'newly selected exact version skips resolver on repeat' test ! -s "$NVM_TEST_CALLS"
|
||||
|
||||
reset_calls
|
||||
builtin cd "$test_dir/outside"
|
||||
check 'leaving project restores default' test "$(command node --version)" = v1.2.3
|
||||
check 'default restoration uses nvm' has_call 'use default --silent'
|
||||
|
||||
builtin cd -q "$test_dir/project"
|
||||
for requested in default 1 1.2 1.2.3 $'v1.2.3\r'; do
|
||||
print -r -- "$requested" > .nvmrc
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check "resolver retained for ${(qqq)requested}" has_call 'version '
|
||||
done
|
||||
|
||||
print -r -- v1.2.3 > .nvmrc
|
||||
print -r -- v2.0.0 > "$NVM_DIR/alias/v1.2.3"
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'numeric alias overrides apparent exact version' test "$(command node --version)" = v2.0.0
|
||||
rm "$NVM_DIR/alias/v1.2.3"
|
||||
nvm use default --silent
|
||||
|
||||
path=("$test_dir/system" $path)
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'same-version system executable still uses resolver' has_call 'version v1.2.3'
|
||||
path=(${path:#$test_dir/system})
|
||||
|
||||
node() { command node "$@"; }
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'node function retains resolver' has_call 'version v1.2.3'
|
||||
unfunction node
|
||||
|
||||
alias node='command node'
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'node alias retains resolver' has_call 'version v1.2.3'
|
||||
unalias node
|
||||
|
||||
print -r -- '#!/bin/sh
|
||||
printf "%s\n" v2.0.0' > "$NVM_DIR/versions/node/v1.2.3/bin/node"
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'executable version mismatch retains resolver' has_call 'version v1.2.3'
|
||||
|
||||
print -r -- '#!/bin/sh
|
||||
printf "%s\n" v1.2.3' > "$NVM_DIR/versions/node/v1.2.3/bin/node"
|
||||
chmod -x "$NVM_DIR/versions/node/v1.2.3/bin/node"
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'non-executable runtime keeps install path' has_call install
|
||||
chmod +x "$NVM_DIR/versions/node/v1.2.3/bin/node"
|
||||
|
||||
print -r -- v99.0.0 > .nvmrc
|
||||
reset_calls
|
||||
load-nvmrc
|
||||
check 'missing version keeps install path' has_call install
|
||||
|
||||
print -r -- "$tests tests, $failures failures"
|
||||
(( failures == 0 ))
|
||||
Reference in new issue
Block a user