Skip to content

Commit

Permalink
Add tool versioning with mise (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
abogoyavlensky authored Jun 3, 2024
1 parent 6515c29 commit 7f5be54
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 96 deletions.
14 changes: 14 additions & 0 deletions .github/actions/cache-deps/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Install and cache deps
runs:
using: composite
steps:
- uses: jdx/mise-action@v2
- name: Cache Clojure dev dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-clojure-dev-${{ hashFiles('**/deps.edn') }}
restore-keys: ${{ runner.os }}-clojure-dev
- name: Install Clojure dev deps
shell: bash
run: make deps
11 changes: 11 additions & 0 deletions .github/actions/restore-deps/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Restore deps
runs:
using: composite
steps:
- uses: jdx/mise-action@v2
- name: Restore cached clojure dev deps
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-clojure-dev-${{ hashFiles('**/deps.edn') }}
restore-keys: ${{ runner.os }}-clojure-dev
34 changes: 34 additions & 0 deletions .github/workflows/_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Checks


on:
workflow_call:

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- name: Fmt
run: make fmt-check

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/restore-deps
- name: Lint
run: make lint-init && make lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/restore-deps
- name: Run tests
env:
DATABASE_HOST_PORT: "localhost:5555"
run: |
docker-compose up -d test-postgres
make test-ci
37 changes: 0 additions & 37 deletions .github/workflows/checks.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Checks


on:
push:
branches: [ master ]

jobs:
deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cache-deps

checks:
needs: [ deps ]
uses: ./.github/workflows/_checks.yaml
26 changes: 26 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Checks


on:
pull_request:
branches: [ master ]

jobs:
deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cache-deps

checks:
needs: [ deps ]
uses: ./.github/workflows/_checks.yaml

outdated:
runs-on: ubuntu-latest
needs: [ deps ]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/restore-deps
- name: Outdated deps
run: make outdated
23 changes: 7 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,24 @@ on:


jobs:
check:
deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cache-deps

- name: Lint
run: docker-compose run --rm check bash -c "make deps && make lint-init > /dev/null 2>&1 || true && make lint"

- name: Fmt
run: docker-compose run --rm check make fmt-check

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Test
run: docker-compose run --rm test bash -c "make deps && make test-ci"
checks:
needs: [ deps ]
uses: ./.github/workflows/_checks.yaml

# deploy:
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# steps:
# - uses: actions/checkout@v4
#
# - uses: jdx/mise-action@v2
# - name: Build jar-file and deploy to Clojars
# run: docker-compose run --rm build bash -c "make deploy-ci"
# run: make deploy-ci
# env:
# CLOJARS_PASSWORD: ${{secrets.CLOJARS_PASSWORD}}
# CLOJARS_USERNAME: ${{secrets.CLOJARS_USERNAME}}
7 changes: 7 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tools]
task = "3.37.2"
java = "temurin-21.0.2+13.0.LTS"
clojure = "1.11.3.1463"
cljstyle = "0.16.626"
clj-kondo = "2024.05.24"
lefthook = "1.6.14"
17 changes: 2 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ help:
.PHONY: deps # Install deps
deps:
@$(INFO) "Install deps..."
@clojure -P -X:test:dev
@clojure -P -X:test:dev:outdated


.PHONY: repl # Running repl
Expand Down Expand Up @@ -52,8 +52,7 @@ lint:
.PHONY: lint-init # Linting code with libraries
lint-init:
@$(INFO) "Linting project's classpath..."
@clj-kondo --parallel --lint $(shell clj -Spath)
@clj-kondo --dependencies --copy-configs --lint $(DIRS)
@clj-kondo --parallel --dependencies --copy-configs --lint $(shell clj -Spath)


.PHONY: outdated # Check deps versions
Expand Down Expand Up @@ -91,18 +90,6 @@ up:
@docker-compose up -d db test-postgres


.PHONY: ps # List docker containers
ps:
@$(INFO) "List docker containers..."
@docker-compose ps


.PHONY: stop # Stop docker containers
stop:
@$(INFO) "Stopping docker containers..."
@docker-compose stop


# Testing commands

.PHONY: migrations # Making migrations
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,14 @@ $ java -jar target/standalone.jar

## Development

### Install system deps

Install [mise-en-place](https://mise.jdx.dev/getting-started.html#quickstart) and run:

```shell
mise install
```

### Run locally

```shell
Expand Down
26 changes: 0 additions & 26 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: "3.8"

services:
check:
image: abogoyavlensky/clojure-temurin17-build:0.1.1
volumes:
- .:/app

db:
image: postgres:14-alpine
ports:
Expand All @@ -25,24 +20,3 @@ services:
POSTGRES_DB: automigrate
POSTGRES_USER: automigrate
POSTGRES_PASSWORD: automigrate

# For testing in CI

test:
image: abogoyavlensky/clojure-temurin17-build:0.1.1
depends_on:
- test-postgres
environment:
DATABASE_HOST_PORT: "test-postgres:5432"
volumes:
- .:/app

# Build jar-file in CI

build:
image: abogoyavlensky/clojure-temurin17-build:0.1.1
environment:
- CLOJARS_PASSWORD
- CLOJARS_USERNAME
volumes:
- .:/app
1 change: 0 additions & 1 deletion src/automigrate/help.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@
(if (some? cmd)
(-> public-methods (fn-docstring cmd) (print-out-str))
(-> public-methods (general-help) (print-out-str)))))

1 change: 0 additions & 1 deletion src/automigrate/util/validation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
(not (contains? all-defined-types (-> field-def :type last))))))
(mapv #(keyword (name model-name) (-> % key name)))))
models))

0 comments on commit 7f5be54

Please sign in to comment.