Skip to content

Commit af9db33

Browse files
authored
Mac Support for ShellCheck (#14)
* Mac Support for ShellCheck
1 parent 7bb09a2 commit af9db33

File tree

3 files changed

+66
-55
lines changed

3 files changed

+66
-55
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ jobs:
7373

7474
- name: Check Sonar Metrics
7575
run: |
76-
echo "Checking for any vulnerabilities in Sonar Metrics JSON"
76+
echo "Checking for 0 vulnerabilities in Sonar Metrics JSON"
7777
VULN=$(cat ./blahblah.json | jq -r '.component.measures[] | select(.metric == "vulnerabilities").value')
7878
echo "# of vulnerabilities = ${VULN}"
79-
[ ${VULN} -eq "0" ]
79+
[ "${VULN}" -eq "0" ]
80+
81+
echo "Checking for any issues <= 2 in Sonar Metrics JSON"
82+
ISSUES=$(cat ./blahblah.json | jq -r '.component.measures[] | select(.metric == "open_issues").value')
83+
echo "# of issues = ${ISSUES}"
84+
[ "${ISSUES}" -le 2 ]

README.md

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,59 @@
33

44
# Sonarless v1
55

6-
This action and its developer friendly helper scripts enable sonarqube scanning for your repository without a need of a dedicated hosted sonarqube server. It boots up a sonarqube docker instance and enable developers to scan checkout code and give a metric json so that you can check the quality of the code.
6+
This developer-friendly CLI and GitHub Action enable SonarQube scanning for your repository without the need for a dedicated hosted SonarQube server. It starts a SonarQube Docker instance, allowing developers to scan code, check results, and generate a JSON metrics file for automation. This ensures you can easily assess and maintain the quality of your code.
77

88
# What's new
99

1010
Please refer to the [release page](https://github.com/gitricko/sonarless/releases/latest) for the latest release notes.
1111

12-
# Usage
12+
# Use Sonarless in your Local Dev
13+
14+
To install CLI, paste and run the following in a terminal:
15+
> `curl -s "https://raw.githubusercontent.com/gitricko/sonarless/main/install.sh" | bash`
16+
17+
```ssh
18+
_
19+
___ ___ _ __ __ _ _ __ | | ___ ___ ___
20+
/ __| / _ \ | "_ \ / _` || "__|| | / _ \/ __|/ __|
21+
\__ \| (_) || | | || (_| || | | || __/\__ \\__ \
22+
|___/ \___/ |_| |_| \__,_||_| |_| \___||___/|___/
23+
24+
25+
Now attempting installation...
26+
27+
Looking for a previous installation of SONARLESS...
28+
Looking for docker...
29+
Looking for jq...
30+
Looking for sed...
31+
Installing Sonarless helper scripts...
32+
* Downloading...
33+
34+
######################################################################## 100.0%
35+
36+
Please open a new terminal, or run the following in the existing one:
37+
38+
alias sonarless='/home/runner/.sonarless/makefile.sh'
39+
40+
Then issue the following command:
41+
42+
sonarless help
43+
44+
Enjoy!!!
45+
```
46+
To understand CLI sub-commands, just run `sonarless help`
47+
48+
Usually, you only need to know 2 sub-commands
49+
- `sonarless scan`: to start scanning your code in the current directory will be uploaded for scanning. When the scan is done, just login webui into your local personal instance of sonarqube via [http://localhost:9234](http://localhost:9234) to get details from SonarQube. The default password for `admin` is `sonarless`
50+
51+
- `sonarless results`: to generate `sonar-metrics.json` metrics file in your current directory
52+
53+
To clean up your sonar instance, just run `sonarless docker-clean`. SonarQube docker instance will be stop and all images removed.
54+
55+
This CLI works perfectly with Github CodeSpace
56+
57+
58+
# GitHub Action Usage
1359

1460
<!-- start usage -->
1561
```yaml
@@ -110,51 +156,6 @@ jobs:
110156
sonar-instance-port: '1234'
111157
```
112158

113-
# Use Sonarless in your Local Dev
114-
115-
To install automation scriptlets, paste and run the following in a terminal:
116-
> `curl -s "https://raw.githubusercontent.com/gitricko/sonarless/main/install.sh" | bash`
117-
118-
```ssh
119-
_
120-
___ ___ _ __ __ _ _ __ | | ___ ___ ___
121-
/ __| / _ \ | "_ \ / _` || "__|| | / _ \/ __|/ __|
122-
\__ \| (_) || | | || (_| || | | || __/\__ \\__ \
123-
|___/ \___/ |_| |_| \__,_||_| |_| \___||___/|___/
124-
125-
126-
Now attempting installation...
127-
128-
Looking for a previous installation of SONARLESS...
129-
Looking for docker...
130-
Looking for jq...
131-
Looking for sed...
132-
Installing Sonarless helper scripts...
133-
* Downloading...
134-
135-
######################################################################## 100.0%
136-
137-
Please open a new terminal, or run the following in the existing one:
138-
139-
alias sonarless='/home/runner/.sonarless/makefile.sh'
140-
141-
Then issue the following command:
142-
143-
sonarless help
144-
145-
Enjoy!!!
146-
```
147-
To understand the sub-commands, just run `sonarless help`
148-
149-
Usually, you only need to know 2 sub-commands
150-
- `sonarless scan`: to start scanning your code in the current directory will be uploaded for scanning. When the scan is done, just login webui into your local personal instance of sonarqube via [http://localhost:9234](http://localhost:9234) to get details from SonarQube. The default password for `admin` is `sonarless`
151-
152-
- `sonarless results`: to generate `sonar-metrics.json` metrics file in your current directory
153-
154-
To clean up your sonar instance, just run `sonarless docker-clean`. SonarQube docker instance will be stop and all images removed.
155-
156-
This small scriptlet works perfectly with Github CodeSpace
157-
158159
# Coffee
159160

160161
If you find this small helper script and action helpful, buy me a [sip of coffee](https://ko-fi.com/gitricko) here to show your appreciation (only if you want to)

makefile.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,24 @@ function sonar-ext-get() {
168168

169169
if [ ! -f "${SONAR_EXTENSION_DIR}/shellcheck" ]; then
170170
# src: https://github.com/koalaman/shellcheck/blob/master/Dockerfile.multi-arch
171-
arch="$(uname -m)";
172-
tag=latest
171+
arch="$(uname -m)"
172+
os="$(uname | sed 's/.*/\L&/')"
173+
tag="v0.10.0"
173174

174175
if [ "${arch}" = 'armv7l' ]; then
175-
arch='armv6hf';
176+
arch='armv6hf'
177+
fi
178+
179+
if [ "${arch}" = 'arm64' ]; then
180+
arch='aarch64'
176181
fi
177182

178183
url_base='https://github.com/koalaman/shellcheck/releases/download/'
179-
tar_file="${tag}/shellcheck-${tag}.linux.${arch}.tar.xz";
184+
tar_file="${tag}/shellcheck-${tag}.${os}.${arch}.tar.xz"
180185
curl -s --fail --location --progress-bar "${url_base}${tar_file}" | tar xJf -
181186

182-
mv "shellcheck-${tag}/shellcheck" "${SONAR_EXTENSION_DIR}/";
183-
rm -rf "shellcheck-${tag}";
187+
mv "shellcheck-${tag}/shellcheck" "${SONAR_EXTENSION_DIR}/"
188+
rm -rf "shellcheck-${tag}"
184189
fi
185190

186191
SONAR_SHELLCHECK="sonar-shellcheck-plugin-2.5.0.jar"

0 commit comments

Comments
 (0)