From dbac910c89b1da9ebbf455c4b9d0b2e3321d89e2 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Mon, 1 Jul 2024 11:10:44 +0200 Subject: [PATCH 1/5] Add github action for running tests --- .github/workflow/test.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflow/test.yml diff --git a/.github/workflow/test.yml b/.github/workflow/test.yml new file mode 100644 index 0000000..4e2a549 --- /dev/null +++ b/.github/workflow/test.yml @@ -0,0 +1,32 @@ +name: Run tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + + - name: Start containers + run: docker-compose up -d + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + + - name: Stop containers + if: always() + run: docker-compose down From e7ccb5b14fd57a88c6a1aa17b28035753a9ba0a1 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Mon, 1 Jul 2024 11:11:34 +0200 Subject: [PATCH 2/5] Rename dir --- .github/{workflow => workflows}/test.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/test.yml (100%) diff --git a/.github/workflow/test.yml b/.github/workflows/test.yml similarity index 100% rename from .github/workflow/test.yml rename to .github/workflows/test.yml From 1a3d7c8995556eb0b2b21955c02bdee2a0c885b7 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Mon, 1 Jul 2024 11:27:13 +0200 Subject: [PATCH 3/5] Test if volumes are breaking --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0dfb0e4..bafe68a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,8 @@ services: command: etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd:2379 --data-dir /etcd-data ports: - "2379:2379" - volumes: - - ./etcd-data:/etcd-data +# volumes: +# - ./etcd-data:/etcd-data minio: image: quay.io/minio/minio command: server /data --console-address ":9001" @@ -15,5 +15,5 @@ services: environment: MINIO_ROOT_USER: minio MINIO_ROOT_PASSWORD: minio123 - volumes: - - ./minio-data:/data +# volumes: +# - ./minio-data:/data From 86499377c8f0becf2ea8b19c3aa05aaf96b215e0 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Mon, 1 Jul 2024 11:30:54 +0200 Subject: [PATCH 4/5] Fix tests --- .github/workflows/test.yml | 4 ++-- docker-compose-github.yml | 17 +++++++++++++++++ docker-compose.yml | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 docker-compose-github.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e2a549..41fc525 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: go-version: '1.22' - name: Start containers - run: docker-compose up -d + run: docker-compose up -d -f docker-compose-github.yml - name: Build run: go build -v ./... @@ -29,4 +29,4 @@ jobs: - name: Stop containers if: always() - run: docker-compose down + run: docker-compose down -f docker-compose-github.yml diff --git a/docker-compose-github.yml b/docker-compose-github.yml new file mode 100644 index 0000000..976f6d9 --- /dev/null +++ b/docker-compose-github.yml @@ -0,0 +1,17 @@ +# go build breaks in GitHub Actions when docker mounts volumes. + +services: + etcd: + image: quay.io/coreos/etcd:v3.5.13 + command: etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd:2379 --data-dir /etcd-data + ports: + - "2379:2379" + minio: + image: quay.io/minio/minio + command: server /data --console-address ":9001" + ports: + - "9000:9000" + - "9001:9001" + environment: + MINIO_ROOT_USER: minio + MINIO_ROOT_PASSWORD: minio123 diff --git a/docker-compose.yml b/docker-compose.yml index bafe68a..0dfb0e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,8 @@ services: command: etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd:2379 --data-dir /etcd-data ports: - "2379:2379" -# volumes: -# - ./etcd-data:/etcd-data + volumes: + - ./etcd-data:/etcd-data minio: image: quay.io/minio/minio command: server /data --console-address ":9001" @@ -15,5 +15,5 @@ services: environment: MINIO_ROOT_USER: minio MINIO_ROOT_PASSWORD: minio123 -# volumes: -# - ./minio-data:/data + volumes: + - ./minio-data:/data From fc92593d4af7668e0ecc6b5a40bb35b74b88a411 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Mon, 1 Jul 2024 11:32:14 +0200 Subject: [PATCH 5/5] Change workflow --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41fc525..2f6f857 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: go-version: '1.22' - name: Start containers - run: docker-compose up -d -f docker-compose-github.yml + run: docker-compose -f docker-compose-github.yml up -d - name: Build run: go build -v ./... @@ -29,4 +29,4 @@ jobs: - name: Stop containers if: always() - run: docker-compose down -f docker-compose-github.yml + run: docker-compose -f docker-compose-github.yml down