Skip to content

Delete event v2

Delete event v2 #138

Workflow file for this run

---
name: Continuous Integration
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches: ["!main", "!staging"]
permissions:
contents: read
statuses: write
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
Test:
runs-on: ubuntu-latest
services:
redis:
image: redis:alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: cosmic_sync_test
MYSQL_ROOT_PASSWORD: cosmic_sync
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Protobuf Compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Build
run: cargo build --verbose --features redis-cache
- name: Test
run: cargo test --verbose
env:
DATABASE_URL: mysql://root:cosmic_sync@localhost:3306/cosmic_sync_test
REDIS_HOST: localhost
REDIS_PORT: 6379
DB_HOST: localhost
Format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Format Check
run: cargo fmt --check
Clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Protobuf Compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Clippy
run: cargo clippy -- -W warnings
Build:
name: Build
needs: [Test, Format, Clippy]
runs-on: ubuntu-latest
steps:
- name: All checks passed (aggregate)
run: echo "All checks passed"
- name: Report commit status (Build)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
SHA="${{ github.event.pull_request.head.sha }}";
else
SHA="${{ github.sha }}";
fi;
for CTX in Build BuildExpected; do
curl -sS -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/$SHA \
-d "{\"state\":\"success\",\"context\":\"$CTX\",\"description\":\"CI checks passed\"}";
done