Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitHub Action Workflow to build sdks and test server #16

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
collect_sdks:
runs-on: ubuntu-latest
outputs:
sdks: ${{ steps.sdks.outputs.sdks }}
steps:
- uses: actions/checkout@v4
- id: sdks
run: echo "sdks=$(cd sdks && ls -d * | jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}

build:
runs-on: ubuntu-latest
needs: collect_sdks
strategy:
matrix:
sdks: ${{ fromJson(needs.collect_sdks.outputs.sdks) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build SDK Docker Images
uses: docker/build-push-action@v6
with:
context: sdks/${{ matrix.sdks }}
push: false

battle:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker Compose Services
run: docker compose build

- name: Run Docker Compose
run: docker compose up server

- name: Collect Test Results
uses: actions/upload-artifact@v3
with:
name: game-results
path: ./server/results/
nhazekam marked this conversation as resolved.
Show resolved Hide resolved

- name: Tear Down Docker Compose
if: always()
run: docker compose down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ game-log.txt
test-log.txt
sdks/clojure/target
.vscode

.fake
23 changes: 22 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,36 @@ version: '3.8'
services:
p1:
build:
context: sdks/java
context: sdks/ruby
dockerfile: Dockerfile
ports:
- "9091:9090"
networks:
- app-network

p2:
build:
context: sdks/ruby
dockerfile: Dockerfile
ports:
- "9092:9090"
depends_on:
- p1
networks:
- app-network

server:
build:
context: server
dockerfile: Dockerfile
ports:
- "9090:9090"
depends_on:
- p2
networks:
- app-network

networks:
app-network:
driver: bridge

2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY Gemfile Gemfile
RUN bundle install

COPY . .
CMD ["ruby", "src/app.rb", "-nu", "-f", "-p1p", "9091", "-p1", "127.0.0.1", "-p2p", "9092", "-p2", "127.0.0.1" ]
CMD ["ruby", "src/app.rb", "-nu", "-f", "-p1p", "9090", "-p1", "p1", "-p2p", "9090", "-p2", "p2" ]