Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shellcheck to circleci #2835

Merged
merged 12 commits into from
Nov 9, 2021

Conversation

hirasawayuki
Copy link
Contributor

@hirasawayuki hirasawayuki commented Nov 3, 2021

Add shellcheck to the ci pipeline for testing and security improvements.

Related issue(s)

Closes #2832

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security. vulnerability, I
    confirm that I got green light (please contact
    security@ory.sh) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

I have confirmed that all the parts pointed out by shellcheck have been fixed in my local environment.

$ shellcheck ./**/*.sh

@CLAassistant
Copy link

CLAassistant commented Nov 3, 2021

CLA assistant check
All committers have signed the CLA.

@@ -94,6 +93,7 @@ hey -n $numReqs -c $numParallel -m POST \
| tee -a BENCHMARKS.md


# shellcheck disable=SC2006
Copy link
Contributor Author

@hirasawayuki hirasawayuki Nov 3, 2021

Choose a reason for hiding this comment

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

I set it to disable because it is a backtick that is written in markdown.
https://github.com/koalaman/shellcheck/wiki/SC2006

@@ -368,7 +368,6 @@ EOF
PROJECT_NAME="hydra"
OWNER=ory
REPO="hydra"
BINARY=hydra
Copy link
Contributor Author

@hirasawayuki hirasawayuki Nov 3, 2021

Choose a reason for hiding this comment

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

It was an unused variable, so it was removed.
https://github.com/koalaman/shellcheck/wiki/SC2034

@@ -56,7 +56,6 @@ hydra clients create \
--endpoint http://localhost:9001

echo "Generating initial access tokens for token introspection benchmark"
authToken=$(hydra token client --endpoint http://localhost:9000 --client-id $clientId --client-secret $clientSecret)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was an unused variable, so it was removed.
https://github.com/koalaman/shellcheck/wiki/SC2034

@@ -3,4 +3,5 @@
set -euxo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )/../.."

docker-compose -f quickstart.yml -f quickstart-postgres.yml -f test/conformance/docker-compose.yml up "${1:-}" -d
# shellcheck disable=SC2086
docker-compose -f quickstart.yml -f quickstart-postgres.yml -f test/conformance/docker-compose.yml up ${1:-} -d
Copy link
Contributor Author

@hirasawayuki hirasawayuki Nov 3, 2021

Choose a reason for hiding this comment

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

I used double-quote, but it had unnecessary empty characters, so I disabled SC2086.

                                                                                                      ↓ this
docker-compose -f quickstart.yml -f quickstart-postgres.yml -f test/conformance/docker-compose.yml up '' -d

@@ -1,6 +1,7 @@
#!/bin/bash

source $HOME/.profile
# shellcheck disable=SC1090,SC1091
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set it to disable because it was a non-existent file when shellcheck is running.
https://github.com/koalaman/shellcheck/wiki/SC1090
https://github.com/koalaman/shellcheck/wiki/SC1091

@hirasawayuki
Copy link
Contributor Author

hirasawayuki commented Nov 3, 2021

Shellcheck checks all passed, but the prettier checks don't seem to pass 🤔

Error Log

#!/bin/bash -eo pipefail
cd docs/
npx prettier --check $(jq -r '.config.prettierTarget' package.json)

Checking formatting...
[warn] docs/guides/oauth2-public-spa-mobile.mdx
[warn] Code style issues found in the above file(s). Forgot to run Prettier?

Exited with code exit status 1
CircleCI received exit code 1

Can I ignore the prettier check, since it seems to have failed in other PRs?

@aeneasr
Copy link
Member

aeneasr commented Nov 4, 2021

Run make format to format all files :)

@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #2835 (7ae40aa) into master (f15f339) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2835   +/-   ##
=======================================
  Coverage   49.87%   49.87%           
=======================================
  Files         236      236           
  Lines       14974    14974           
=======================================
  Hits         7469     7469           
  Misses       6843     6843           
  Partials      662      662           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50f9dc8...7ae40aa. Read the comment docs.

@hirasawayuki
Copy link
Contributor Author

Run make format to format all files :)

Thankyou @aeneasr
I ran make format and it passed all the checks!

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Great job!

@aeneasr aeneasr merged commit 38cbcc0 into ory:master Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add shellcheck to circleci
3 participants