Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Aug 22, 2023
1 parent 5667a0b commit 85b5a82
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 30 deletions.
25 changes: 25 additions & 0 deletions .github/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
#!/bin/sh

set -e
rubyfiles=$(git diff --cached --name-only --diff-filter=ACM "*.rb" "Gemfile" | tr '\n' ' ')
[ -z "$rubyfiles" ] && exit 0

# Standardize all ruby files
echo "🧹 Formatting staged Ruby files using standardrb ($(echo $rubyfiles | wc -w | awk '{print $1}') total)"
echo "$rubyfiles" | xargs docker-compose run --rm web bundle exec standardrb --fix

# Add back the modified/prettified files to staging
echo "$rubyfiles" | xargs git add

echo "📋 Running tests with rspec"
docker-compose run --rm web bundle exec rspec --format progress

exit 0
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Create .env file
run: cat .env-example .env-dev-values > .env
run: cat env.* > .env
- name: Load .env file
uses: xom9ikk/dotenv@v2
- name: Set up Ruby 3.2
Expand Down
34 changes: 6 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,19 @@ git clone git@github.com:mlibrary/get-this.git
cd get-this
```

copy .env-example to .env

```
cp .env-example .env
```

edit .env with actual environment variables; ask a developer if you need them

build container
```
docker-compose build
```

bundle install
```
docker-compose run --rm web bundle install
run the `init.sh` script.
```bash
./init.sh
```

npm install
```
docker-compose run --rm web npm install
```

build the css

```
docker-compose run --rm web npm run build
```
edit .env with the appropriate environment variables

start containers
```

```bash
docker-compose up -d
```


## Updating `institution_hours_exceptions.json`

`config/institution_hours_exceptions.json` is a static file that needs to be updated yearly.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- gem_cache:/gems
env_file:
- .env
- .env-dev-values
- env.development
command:
- bundle
- exec
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

#must be run from the project root directory
if [ -f ".env" ]; then
echo "🌎 .env exists. Leaving alone"
else
echo "🌎 .env does not exist. Copying env.example to .env"
cp env.example .env
fi

if [ -f ".git/hooks/pre-commit" ]; then
echo "🪝 .git/hooks/pre-commit exists. Leaving alone"
else
echo " 🪝 .git/hooks/pre-commit does not exist. Copying .github/pre-commit to .git/hooks/"
cp .github/pre-commit .git/hooks/pre-commit
fi

echo "🚢 Build docker images"
docker-compose build

echo "📦 Installing Gems"
docker-compose run --rm web bundle

echo "📦 Installing Node modules"
docker-compose run --rm web npm install

echo "📦 Building js and css"
docker-compose run --rm web npm run build

0 comments on commit 85b5a82

Please sign in to comment.