Skip to content

Commit 2ee2069

Browse files
Add tests and set up a CI workflow
Add a test setup based on Docker images. Currently, uses "MinIO" on the Github CI. fixes #6
1 parent 143c811 commit 2ee2069

File tree

11 files changed

+467
-11
lines changed

11 files changed

+467
-11
lines changed

.ameba.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This configuration file was generated by `ameba --gen-config`
2+
# on 2025-08-11 12:55:55 UTC using Ameba version 1.6.4.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the reported problems are removed from the code base.
5+
6+
# Problems found: 1
7+
# Run `ameba --only Documentation/DocumentationAdmonition` for details
8+
Documentation/DocumentationAdmonition:
9+
Description: Reports documentation admonitions
10+
Timezone: UTC
11+
Excluded:
12+
- src/easy-awscr/s3/client.cr
13+
Admonitions:
14+
- TODO
15+
- FIXME
16+
- BUG
17+
Enabled: true
18+
Severity: Warning

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Crystal CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build-ubuntu:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
crystal: [latest, nightly]
15+
runs-on: ubuntu-latest
16+
17+
# Setup copied from the aswscr-s3 project:
18+
# https://github.com/taylorfinnell/awscr-s3/blob/44d9da5cc6e1361a04df9c45b5765af322db0556/.github/workflows/test.yml#L26C1-L41C30
19+
services:
20+
minio:
21+
# https://stackoverflow.com/questions/60849745/how-can-i-run-a-command-in-github-action-service-containers
22+
image: bitnami/minio:latest
23+
env:
24+
MINIO_ROOT_USER: admin
25+
MINIO_ROOT_PASSWORD: password
26+
ports:
27+
- 9000:9000
28+
# https://github.com/orgs/community/discussions/26688
29+
options: >-
30+
--health-cmd "curl -s http://localhost:9000/minio/health/live"
31+
--health-interval=10s
32+
--health-timeout=5s
33+
--health-retries=5
34+
--name minio-server
35+
36+
steps:
37+
- name: Install Crystal
38+
uses: oprypin/install-crystal@v1
39+
with:
40+
crystal: ${{ matrix.crystal }}
41+
42+
- name: Download source
43+
uses: actions/checkout@v4
44+
45+
- name: Check code formatting
46+
run: crystal tool format --check
47+
48+
- name: Install dependencies
49+
run: shards install
50+
51+
- name: Lint with Ameba
52+
run: bin/ameba
53+
54+
- name: Run specs
55+
run: crystal spec --verbose --tag '~slow' --order random
56+
env:
57+
EASY_AWSCR_SPEC_USE_MINIO: true
58+
59+
60+
# Without Docker, tests can be still executed, but they will be crippled.
61+
build-macos-without-docker:
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
crystal: [latest, nightly]
66+
runs-on: macos-latest
67+
68+
steps:
69+
- name: Install Crystal
70+
uses: oprypin/install-crystal@v1
71+
with:
72+
crystal: ${{ matrix.crystal }}
73+
74+
- name: Download source
75+
uses: actions/checkout@v4
76+
77+
- name: Check code formatting
78+
run: crystal tool format --check
79+
80+
- name: Install dependencies
81+
run: shards install
82+
83+
- name: Lint with Ameba
84+
run: bin/ameba
85+
86+
- name: Run specs
87+
run: crystal spec --verbose --tag '~slow' --order random
88+
89+
- name: Run specs
90+
run: crystal spec --verbose --tag '~slow' --order random

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/bin/
44
/.shards/
55
*.dwarf
6+
*~
67

78
# Libraries don't need dependency lock
89
# Dependencies will be locked in applications that use them

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
all: release
2+
3+
test:
4+
crystal spec --verbose --tag '~slow' --order random
5+
6+
test-all:
7+
crystal spec --verbose --release --order random
8+
9+
linter:
10+
ameba
11+
12+
linter-fix:
13+
ameba --fix
14+
15+
format-check:
16+
crystal tool format --check
17+
18+
format-apply:
19+
crystal tool format
20+
21+
start-minio:
22+
docker run -p 127.0.0.1:9000:9000 -p 127.0.0.1:9001:9001 -e "MINIO_ROOT_USER=admin" -e "MINIO_ROOT_PASSWORD=password" --rm -it quay.io/minio/minio server /data --console-address ":9001"
23+
24+
.PHONY: dist-clean
25+
dist-clean:
26+
rm -rf lib
27+
rm -rf bin
28+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ client.delete_bucket(test_bucket)
8787

8888
The bulk of the work is done by the libraries `aws-credentials.cr` and `awscr-s3`.
8989

90+
### How to run tests
91+
92+
Run tests:
93+
94+
```
95+
crystal spec --verbose --tag '~slow'
96+
```
97+
98+
Run all tests, including slow, memory-intensive test:
99+
100+
```
101+
crystal spec --verbose
102+
```
103+
104+
Note: alias for these commands can also be found in the `Makefile` (e.g. `make test`).
105+
90106
## Contributing
91107

92108
1. Fork it (<https://github.com/philipp-classen/easy-awscr/fork>)

shard.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ dependencies:
1414
github: taylorfinnell/awscr-s3
1515
commit: 2e93fb9e8c74f11a24c5808fc4b1f8b304181830
1616

17+
development_dependencies:
18+
ameba:
19+
github: crystal-ameba/ameba
20+
1721
license: MIT

spec/easy-awscr_spec.cr

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)