Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

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

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
container:
image: swift:6.3-noble
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: vapor_username
POSTGRES_PASSWORD: vapor_password
POSTGRES_DB: vapor_test
ports:
- 5432:5432
env:
DATABASE_HOST: postgres
DATABASE_USERNAME: vapor_username
DATABASE_PASSWORD: vapor_password
DATABASE_NAME: vapor_test
steps:
- uses: actions/checkout@v4
- name: Run tests with coverage
run: swift test --enable-code-coverage
- name: Generate coverage report
if: always()
run: |
BIN_PATH="$(swift build --show-bin-path)"
XCTEST_PATH="$(find "$BIN_PATH" -name '*.xctest')"
IGNORE_FILENAME_REGEX="(\.build|TestUtils|Tests)"

llvm-cov export "$XCTEST_PATH" \
--format=lcov \
--instr-profile=".build/debug/codecov/default.profdata" \
--ignore-filename-regex="$IGNORE_FILENAME_REGEX" > coverage.lcov

{
echo "### Code coverage"
echo
echo '```'
llvm-cov report "$XCTEST_PATH" \
--instr-profile=".build/debug/codecov/default.profdata" \
--ignore-filename-regex="$IGNORE_FILENAME_REGEX"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.lcov

lint:
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-setup@v1
- name: Run SwiftLint
run: |
docker run --rm -v "$PWD:/work" -w /work ghcr.io/realm/swiftlint:latest \
lint --reporter checkstyle > swiftlint-report.xml
- name: Annotate with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
reviewdog -f=checkstyle -name=swiftlint -reporter=github-check \
-filter-mode=nofilter -fail-level=error < swiftlint-report.xml
93 changes: 93 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build & Deploy

on:
push:
branches: [develop, main]
workflow_dispatch:

concurrency:
group: deploy-${{ github.ref_name }}

jobs:
build:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/megamek/api-data:${{ github.ref_name }}

deploy-staging:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
environment:
name: staging
url: https://api.battletech.dev
steps:
- uses: actions/checkout@v4
- name: Install Ansible
run: |
python3 -m pip install --upgrade pip
pip install ansible
ansible-galaxy collection install community.docker
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H api.battletech.dev >> ~/.ssh/known_hosts
- name: Write Ansible template vars
run: |
echo "${{ secrets.STAGING_DATABASE_HOST }}" > ansible/templates/database_host
echo "${{ secrets.STAGING_DATABASE_NAME }}" > ansible/templates/database_name
echo "${{ secrets.STAGING_DATABASE_PASSWORD }}" > ansible/templates/database_password
echo "${{ secrets.STAGING_DATABASE_USERNAME }}" > ansible/templates/database_username
echo "${{ github.actor }}" > ansible/templates/username
echo "${{ secrets.GHCR_READ_TOKEN }}" > ansible/templates/password
echo "${{ secrets.SENDGRID_API_KEY }}" > ansible/templates/sendgrid
- name: Deploy
run: ansible-playbook ansible/staging.yml

deploy-production:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: production
url: https://api.quartermaster-command.services
steps:
- uses: actions/checkout@v4
- name: Install Ansible
run: |
python3 -m pip install --upgrade pip
pip install ansible
ansible-galaxy collection install community.docker
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H api.battletech.games >> ~/.ssh/known_hosts
- name: Write Ansible template vars
run: |
echo "${{ secrets.PRODUCTION_DATABASE_HOST }}" > ansible/templates/database_host
echo "${{ secrets.PRODUCTION_DATABASE_NAME }}" > ansible/templates/database_name
echo "${{ secrets.PRODUCTION_DATABASE_PASSWORD }}" > ansible/templates/database_password
echo "${{ secrets.PRODUCTION_DATABASE_USERNAME }}" > ansible/templates/database_username
echo "${{ github.actor }}" > ansible/templates/username
echo "${{ secrets.GHCR_READ_TOKEN }}" > ansible/templates/password
echo "${{ secrets.SENDGRID_API_KEY }}" > ansible/templates/sendgrid
- name: Deploy
run: ansible-playbook ansible/production.yml
45 changes: 45 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish DocC to GitHub Pages

on:
push:
branches: [develop]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
container:
image: swift:6.3-noble
steps:
- uses: actions/checkout@v4
- name: Generate DocC documentation
run: |
swift package --allow-writing-to-directory ./docs \
generate-documentation \
--target App \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path ${{ github.event.repository.name }} \
--output-path ./docs
- uses: actions/upload-pages-artifact@v3
with:
path: docs

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ansible/templates/database*
ansible/templates/password
ansible/templates/username
ansible/templates/sendgrid
ansible/templates/redis_url
*.profraw
coverage.info
coverage/*
Expand Down
97 changes: 0 additions & 97 deletions .gitlab-ci.yml

This file was deleted.

Loading
Loading