feat: setup CI
This commit is contained in:
parent
b61fde3873
commit
72df0769b3
5 changed files with 313 additions and 0 deletions
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
# patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
# ko_fi: # Replace with a single Ko-fi username
|
||||||
|
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: realaravinth
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
# otechie: # Replace with a single Otechie username
|
||||||
|
custom: ['https://batsense.net/donate']
|
43
.github/workflows/clippy-fmt.yml
vendored
Normal file
43
.github/workflows/clippy-fmt.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: rustfmt
|
||||||
|
- name: Check with rustfmt
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: clippy
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Check with Clippy
|
||||||
|
uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --workspace --tests --all-features
|
82
.github/workflows/coverage.yml
vendored
Normal file
82
.github/workflows/coverage.yml
vendored
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
name: Coverage
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
|
||||||
|
# services:
|
||||||
|
# postgres:
|
||||||
|
# image: postgres
|
||||||
|
# env:
|
||||||
|
# POSTGRES_PASSWORD: password
|
||||||
|
# POSTGRES_USER: postgres
|
||||||
|
# POSTGRES_DB: postgres
|
||||||
|
# options: >-
|
||||||
|
# --health-cmd pg_isready
|
||||||
|
# --health-interval 10s
|
||||||
|
# --health-timeout 5s
|
||||||
|
# --health-retries 5
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: ⚡ Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
target
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: load env
|
||||||
|
run: |
|
||||||
|
source .env-sample \
|
||||||
|
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
&& echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: run migrations
|
||||||
|
run: make migrate
|
||||||
|
# env:
|
||||||
|
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: Generate coverage file
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
|
uses: actions-rs/tarpaulin@v0.1
|
||||||
|
# env:
|
||||||
|
# # GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||||
|
# # execution so this value is required for preventing meta tests from
|
||||||
|
# # panicking
|
||||||
|
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
with:
|
||||||
|
args: "--all-features --no-fail-fast --workspace=database/db-sqlx-postgres,database/db-sqlx-sqlite,. -t 1200"
|
||||||
|
|
||||||
|
- name: Upload to Codecov
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
|
uses: codecov/codecov-action@v2
|
117
.github/workflows/linux.yml
vendored
Normal file
117
.github/workflows/linux.yml
vendored
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
# - nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# services:
|
||||||
|
# postgres:
|
||||||
|
# image: postgres
|
||||||
|
# env:
|
||||||
|
# POSTGRES_PASSWORD: password
|
||||||
|
# POSTGRES_USER: postgres
|
||||||
|
# POSTGRES_DB: postgres
|
||||||
|
# options: >-
|
||||||
|
# --health-cmd pg_isready
|
||||||
|
# --health-interval 10s
|
||||||
|
# --health-timeout 5s
|
||||||
|
# --health-retries 5
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
#
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: ⚡ Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
/var/lib/docker
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
target
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
# - name: Login to DockerHub
|
||||||
|
# if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'forgeflux-org/world'
|
||||||
|
# uses: docker/login-action@v1
|
||||||
|
# with:
|
||||||
|
# username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
# password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
# - name: load env
|
||||||
|
# run: |
|
||||||
|
# source .env-sample \
|
||||||
|
# && echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
# && echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
#
|
||||||
|
- name: build
|
||||||
|
run: make
|
||||||
|
# env:
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
# - name: build docker images
|
||||||
|
# if: matrix.version == 'stable'
|
||||||
|
# run: make docker
|
||||||
|
#
|
||||||
|
# - name: publish docker images
|
||||||
|
# if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
|
||||||
|
# run: make docker-publish
|
||||||
|
#
|
||||||
|
# - name: run migrations
|
||||||
|
# run: make migrate
|
||||||
|
# env:
|
||||||
|
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
timeout-minutes: 40
|
||||||
|
run: make test
|
||||||
|
# env:
|
||||||
|
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: generate documentation
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
|
||||||
|
run: make doc
|
||||||
|
# env:
|
||||||
|
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
# SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
|
||||||
|
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||||
|
with:
|
||||||
|
branch: gh-pages
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
FOLDER: deploy-static
|
||||||
|
|
||||||
|
# - name: deploy
|
||||||
|
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'realaravinth/realaravinth' }}
|
||||||
|
# run: >-
|
||||||
|
# curl --location --request POST "https://deploy.batsense.net/api/v1/update" --header 'Content-Type: application/json' --data-raw "{ \"secret\": \"${{ secrets.DEPLOY_TOKEN }}\", \"branch\": \"gh-pages\" }"
|
59
Makefile
Normal file
59
Makefile
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
default: ## Debug build
|
||||||
|
cargo build
|
||||||
|
|
||||||
|
clean: ## Clean all build artifacts and dependencies
|
||||||
|
@-/bin/rm -rf target/
|
||||||
|
@-/bin/rm -rf database/migrator/target/
|
||||||
|
@-/bin/rm -rf database/*/target/
|
||||||
|
@-/bin/rm -rf database/*/tmp/
|
||||||
|
@cargo clean
|
||||||
|
|
||||||
|
coverage: migrate ## Generate coverage report in HTML format
|
||||||
|
cargo tarpaulin -t 1200 --out Html --skip-clean --all-features --no-fail-fast --workspace=database/db-sqlx-postgres,database/db-sqlx-sqlite,.
|
||||||
|
|
||||||
|
dev-env: ## Download development dependencies
|
||||||
|
cargo fetch
|
||||||
|
|
||||||
|
doc: ## Prepare documentation
|
||||||
|
cargo doc --no-deps --workspace --all-features
|
||||||
|
|
||||||
|
#docker: ## Build docker images
|
||||||
|
# docker build -t realaravinth/gitpad:master -t realaravinth/gitpad:latest .
|
||||||
|
#
|
||||||
|
#docker-publish: docker ## Build and publish docker images
|
||||||
|
# docker push realaravinth/gitpad:master
|
||||||
|
# docker push realaravinth/gitpad:latest
|
||||||
|
|
||||||
|
lint: ## Lint codebase
|
||||||
|
cargo fmt -v --all -- --emit files
|
||||||
|
cargo clippy --workspace --tests --all-features
|
||||||
|
|
||||||
|
release: ## Release build
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
run: default ## Run debug build
|
||||||
|
cargo run
|
||||||
|
|
||||||
|
migrate: ## run migrations
|
||||||
|
echo TODO: add migrations
|
||||||
|
# @-rm -rf database/db-sqlx-sqlite/tmp && mkdir database/db-sqlx-sqlite/tmp
|
||||||
|
# cd database/migrator && cargo run
|
||||||
|
|
||||||
|
sqlx-offline-data: ## prepare sqlx offline data
|
||||||
|
cargo sqlx prepare --database-url=${POSTGRES_DATABASE_URL} -- --bin gitpad \
|
||||||
|
--all-features
|
||||||
|
|
||||||
|
test: migrate ## Run tests
|
||||||
|
cd database/db-sqlx-postgres &&\
|
||||||
|
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||||
|
cargo test --no-fail-fast
|
||||||
|
cd database/db-sqlx-sqlite &&\
|
||||||
|
DATABASE_URL=${SQLITE_DATABASE_URL}\
|
||||||
|
cargo test --no-fail-fast
|
||||||
|
cargo test
|
||||||
|
|
||||||
|
xml-test-coverage: migrate ## Generate cobertura.xml test coverage
|
||||||
|
cargo tarpaulin -t 1200 --out Xml --skip-clean --all-features --no-fail-fast --workspace=database/db-sqlx-postgres,database/db-sqlx-sqlite,.
|
||||||
|
|
||||||
|
help: ## Prints help for targets with comments
|
||||||
|
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
Loading…
Add table
Reference in a new issue