Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
}
}
},
"image": "mcr.microsoft.com/devcontainers/base:debian",
"mounts": [
"source=${localWorkspaceFolder}/snippets,target=${containerWorkspaceFolder}/.vscode,type=bind,consistency=cached"
],
"image": "mcr.microsoft.com/devcontainers/java:21",
"postCreateCommand": "chmod +x ${containerWorkspaceFolder}/.devcontainer/postCreateScript.sh && ${containerWorkspaceFolder}/.devcontainer/postCreateScript.sh",
"runArgs": [
"--rm",
Expand Down
38 changes: 8 additions & 30 deletions .devcontainer/postCreateScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
##########################################################################################
# File: postCreateScript.sh
# Author: Vatsal Gupta
# Date: 09-Jul-2024
# Description:

# This script runs automatically after the DevContainer environment has been created.
Expand All @@ -30,44 +29,23 @@
##########################################################################################
# Constants
##########################################################################################
readonly SNIPPETS_DIR="snippets"
readonly VSCODE_DIR=".vscode"
readonly SNIPPET_FILES_PATTERN="*.code-snippets"

readonly ALIAS_SRC_URL="https://raw.githubusercontent.com/gvatsal60/Linux-Aliases/HEAD/install.sh"

##########################################################################################
# Functions
##########################################################################################
curl_https() {
if ! command -v curl >/dev/null 2>&1; then
echo "Error: curl is not installed. Aborting." >&2
return 1
fi
curl -fsSL --proto '=https' "$@"
}

##########################################################################################
# Main Script
##########################################################################################

# Install Linux aliases from external script using curl and execute immediately
# Note: Make sure to review scripts fetched from external sources for security reasons
if command -v curl >/dev/null 2>&1; then
curl -fsSL "${ALIAS_SRC_URL}" | sh
else
echo "Error: curl is not installed. Unable to use Linux aliases"
exit 1
fi

# As bind mounts not supported in GitHub Codespaces
if [ -n "${CODESPACE_NAME}" ]; then
# Generate symlinks for snippet files
# Create the .vscode directory if it doesn't already exist.
mkdir -p "${VSCODE_DIR}"
# Unlink all symbolic links in the '.vscode' directory
find "${VSCODE_DIR}" -type l -name "${SNIPPET_FILES_PATTERN}" | while read -r file; do
unlink "${file}"
done
# Check if the 'snippets' directory exists
if [ -d "${SNIPPETS_DIR}" ]; then
# Find all .code-snippet files in the 'snippets' directory and create symbolic links
find "${SNIPPETS_DIR}" -type f -name "${SNIPPET_FILES_PATTERN}" | while read -r file; do
# Create a symbolic link in '.vscode' with the same base name
ln -s "$(realpath "${file}")" "${VSCODE_DIR}/$(basename "${file}")"
done
fi
fi
curl_https "${ALIAS_SRC_URL}" | sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Piping an external script directly from curl to sh is a security risk. Consider downloading the script, verifying its checksum, and then executing it locally.

12 changes: 0 additions & 12 deletions .github/FUNDING.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

8 changes: 0 additions & 8 deletions .github/ISSUE_TEMPLATE/custom.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

4 changes: 4 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
9 changes: 9 additions & 0 deletions .github/workflows/bot-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Trigger Bot Merge
on:
pull_request:
permissions:
pull-requests: write
contents: write
jobs:
call-auto-merge:
uses: gvatsal60/.github/.github/workflows/bot-pr-auto-approve-merge.yaml@08d0834f1b687dbab5353c7fb066d6b938699609
79 changes: 79 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI
on:
push:
branches: [master]
pull_request:
permissions:
contents: read
jobs:
test:
name: Unit Tests (JDK ${{ matrix.java-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java-version: ['11', '17', '21']
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.java-version }}-
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-jdk${{ matrix.java-version }}
path: build/reports/tests/
- name: Upload coverage report
if: matrix.java-version == '17'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: build/reports/jacoco/
- name: Coverage summary
if: matrix.java-version == '17'
run: |
if [ -f build/reports/jacoco/test/jacocoTestReport.csv ]; then
echo "## Coverage Summary" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
head -1 build/reports/jacoco/test/jacocoTestReport.csv >> "$GITHUB_STEP_SUMMARY"
tail -n +2 build/reports/jacoco/test/jacocoTestReport.csv | awk -F',' '{printf "%-40s %s/%s (%.1f%%)\n", $3, $8+$9, $4+$5+$6+$7+$8+$9, ($8+$9)/($4+$5+$6+$7+$8+$9)*100}' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: ${{ runner.os }}-pre-commit-
- name: Install pre-commit
run: pip install pre-commit

Check warning on line 77 in .github/workflows/ci.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=AlwaysTechnical_jenkins-shared-library&issues=AZ-9fHiT-CkDYWnc4F-I&open=AZ-9fHiT-CkDYWnc4F-I&pullRequest=1

Check warning on line 77 in .github/workflows/ci.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=AlwaysTechnical_jenkins-shared-library&issues=AZ-9fHiT-CkDYWnc4F-J&open=AZ-9fHiT-CkDYWnc4F-J&pullRequest=1
- name: Run pre-commit hooks
run: pre-commit run --all-files
17 changes: 0 additions & 17 deletions .github/workflows/dependabot-pr.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/pre-commit-pr.yaml

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write

Check warning on line 7 in .github/workflows/release.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this write permission from workflow level to job level.

See more on https://sonarcloud.io/project/issues?id=AlwaysTechnical_jenkins-shared-library&issues=AZ-9fHib-CkDYWnc4F-L&open=AZ-9fHib-CkDYWnc4F-L&pullRequest=1
jobs:
test:
name: Validate Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/reports/tests/
release:
name: Create Release
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Validate library.json version matches tag
run: |
LIB_VERSION=$(grep -o '"version": *"[^"]*"' resources/org/devops/library.json | grep -o '[0-9][^"]*')
TAG_VERSION="${{ steps.version.outputs.VERSION }}"
if [ "$LIB_VERSION" != "$TAG_VERSION" ]; then
echo "::warning::library.json version ($LIB_VERSION) does not match tag version ($TAG_VERSION)"
fi
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git tag --sort=-v:refname | grep '^v' | head -2 | tail -1)
if [ -z "$PREV_TAG" ] || [ "$PREV_TAG" = "$GITHUB_REF_NAME" ]; then
echo "CHANGELOG<<EOF" >> "$GITHUB_OUTPUT"
git log --pretty=format:"- %s (%h)" HEAD >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
else
echo "CHANGELOG<<EOF" >> "$GITHUB_OUTPUT"
git log --pretty=format:"- %s (%h)" "${PREV_TAG}..HEAD" >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2

Check failure on line 74 in .github/workflows/release.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=AlwaysTechnical_jenkins-shared-library&issues=AZ-9fHib-CkDYWnc4F-K&open=AZ-9fHib-CkDYWnc4F-K&pullRequest=1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
## Changes

${{ steps.changelog.outputs.CHANGELOG }}

## Usage

```groovy
@Library('devops-shared@${{ github.ref_name }}') _
```
generate_release_notes: true
draft: false
prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}
Loading
Loading