Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
codeart1st committed Mar 19, 2023
0 parents commit 78d8319
Show file tree
Hide file tree
Showing 20 changed files with 959 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/actions/post-build-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Post build environment
description: Clean up build environment actions

inputs:
cargo-cache-primary-key:
description: Primary key of cargo cache restore action
required: true
cargo-cache-hit:
description: A boolean value to indicate an exact match was found for the cargo cache restore action
required: true

runs:
using: "composite"
steps:
- name: Cache cargo output (save)
if: inputs.cargo-cache-hit != 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
uses: actions/cache/[email protected]
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/.package-cache
~/.cargo/registry/
~/.cargo/git/db/
target/
key: ${{ inputs.cargo-cache-primary-key }}
62 changes: 62 additions & 0 deletions .github/actions/prepare-build-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Prepare build environment
description: Ensures that everything is prepared for our build jobs

outputs:
cargo-cache-primary-key:
description: Primary key of cargo cache restore action
value: ${{ steps.cargo-cache.outputs.cache-primary-key }}
cargo-cache-hit:
description: A boolean value to indicate an exact match was found for the cargo cache restore action
value: ${{ steps.cargo-cache.outputs.cache-hit }}

runs:
using: "composite"
steps:
- name: Cache rust-toolchain (restore)
id: rustup-cache
uses: actions/cache/[email protected]
with:
path: |
~/.rustup/toolchains
~/.rustup/update-hashes
~/.rustup/settings.toml
key: toolchain-${{ hashFiles('rust-toolchain') }}-1

- name: Use rust-toolchain nightly
if: steps.rustup-cache.outputs.cache-hit != 'true'
shell: bash
run: |
rustup toolchain uninstall stable
rustup toolchain install $(cat rust-toolchain) \
--profile minimal --component clippy,rust-src
- name: Get rust version
id: rustup
shell: bash
run: |
rustup show
echo "version=$(rustc --version | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT
- name: Cache rust-toolchain (save)
uses: actions/cache/[email protected]
if: steps.rustup-cache.outputs.cache-hit != 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
with:
path: |
~/.rustup/toolchains
~/.rustup/update-hashes
~/.rustup/settings.toml
key: ${{ steps.rustup-cache.outputs.cache-primary-key }}

- name: Cache cargo output (restore)
id: cargo-cache
uses: actions/cache/[email protected]
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/.package-cache
~/.cargo/registry/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ steps.rustup.outputs.version }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ github.job }}-1
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2

updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
target-branch: "develop"
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
target-branch: "develop"
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: /.github/actions/prepare-build-env
schedule:
interval: daily
target-branch: "develop"
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: /.github/actions/post-build-env
schedule:
interval: daily
target-branch: "develop"
open-pull-requests-limit: 10
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI

on:
schedule:
- cron: "0 7 * * 1"
push:
pull_request:

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

permissions:
contents: read

jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- name: Checkout repository and submodules
uses: actions/[email protected]
with:
submodules: recursive

- name: Prepare build environemnt
id: prepare
uses: ./.github/actions/prepare-build-env

- name: Run cargo clippy
run: |
cargo clippy --tests -- --deny "warnings"
- name: Post build environemnt
if: always()
uses: ./.github/actions/post-build-env
with:
cargo-cache-primary-key: ${{ steps.prepare.outputs.cargo-cache-primary-key }}
cargo-cache-hit: ${{ steps.prepare.outputs.cargo-cache-hit }}

build:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- name: Checkout repository and submodules
uses: actions/[email protected]
with:
submodules: recursive

- name: Prepare build environemnt
id: prepare
uses: ./.github/actions/prepare-build-env

- name: Run cargo build
run: cargo build

- name: Post build environemnt
if: always()
uses: ./.github/actions/post-build-env
with:
cargo-cache-primary-key: ${{ steps.prepare.outputs.cargo-cache-primary-key }}
cargo-cache-hit: ${{ steps.prepare.outputs.cargo-cache-hit }}

unit-test:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- name: Checkout repository and submodules
uses: actions/[email protected]
with:
submodules: recursive

- name: Prepare build environemnt
id: prepare
uses: ./.github/actions/prepare-build-env

- name: Use libegl1-mesa latest
uses: ./.github/actions/install-graphics-driver

- name: Run cargo test
run: |
cargo test -- --nocapture
- name: Post build environemnt
if: always()
uses: ./.github/actions/post-build-env
with:
cargo-cache-primary-key: ${{ steps.prepare.outputs.cargo-cache-primary-key }}
cargo-cache-hit: ${{ steps.prepare.outputs.cargo-cache-hit }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.vscode
/target
**/*.rs.bk
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "vector-tile-spec"]
path = vector-tile-spec
url = https://github.com/mapbox/vector-tile-spec
[submodule "mvt-fixtures"]
path = mvt-fixtures
url = https://github.com/mapbox/mvt-fixtures
Loading

0 comments on commit 78d8319

Please sign in to comment.