Skip to content

Commit

Permalink
refactor: pre-commit hooks and apply comments on #8
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihendry committed Aug 1, 2023
1 parent c25b059 commit 15abf42
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:
push:

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
- uses: pre-commit-ci/[email protected]
if: always()
27 changes: 21 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: detect-private-key
- repo: https://github.com/compilerla/conventional-pre-commit
rev: 'v2.3.0'
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: ['feat', 'fix', 'ci', 'chore', 'test', 'docs', 'refactor']
- repo: https://github.com/tekwizely/pre-commit-golang
rev: 'v1.0.0-rc.1'
hooks:
- id: go-mod-tidy
- id: go-vet-mod
- id: go-fmt
- id: go-staticcheck-mod
- id: go-sec-mod
- id: go-build-mod
- id: go-test-mod
- id: go-sec-mod
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: detect-private-key
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MaEVe runs in a set of Docker containers. This means you need to have `docker`,
To get the system up and running:

1. `(cd config/certificates && make)`
1. Run the [./scripts/run.sh](./scripts/run.sh) script with the same token to run all the required components - again, don't forget the quotes around the token
2. Run the [./scripts/run.sh](./scripts/run.sh) script with the same token to run all the required components - again, don't forget the quotes around the token

Charge stations can connect to the CSMS using:
* `ws://localhost/ws/<cs-id>`
Expand Down
21 changes: 20 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/usr/bin/env bash

command_exists() {
command -v "$1" >/dev/null 2>&1
}

BEARER_TOKEN=$(curl -s https://hubject.stoplight.io/api/v1/projects/cHJqOjk0NTg5/nodes/6bb8b3bc79c2e-authorization-token | jq -r .data | sed -n '/Bearer/s/^.*Bearer //p')

# fall back to BEARER_TOKEN if no arg
CSO_OPCP_TOKEN="${1:-$BEARER_TOKEN}"
MO_OPCP_TOKEN="${2:-$BEARER_TOKEN}"

export MO_OPCP_TOKEN=$MO_OPCP_TOKEN; export CSO_OPCP_TOKEN=$CSO_OPCP_TOKEN;docker-compose up "${@:2}" --build
shift

# Check if 'docker compose' is available (with space)
if command_exists "docker compose"; then
DOCKER_COMPOSE_CMD="docker compose"
else
# Check if 'docker-compose' is available
if command_exists docker-compose; then
DOCKER_COMPOSE_CMD="docker-compose"
else
echo "Error: Neither 'docker-compose' nor 'docker compose' is available. Please install Docker Compose."
exit 1
fi
fi

export MO_OPCP_TOKEN=$MO_OPCP_TOKEN; export CSO_OPCP_TOKEN=$CSO_OPCP_TOKEN;$DOCKER_COMPOSE_CMD up "${@:2}"

0 comments on commit 15abf42

Please sign in to comment.