Merge pull request #121 from maxammann/refactor-ci

Refactor CI
This commit is contained in:
Max Ammann 2022-06-02 23:41:35 +02:00 committed by GitHub
commit cdc3c0e94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 572 additions and 504 deletions

View File

@ -1,32 +0,0 @@
name: android
description: Build for android
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: just nightly-toolchain-android
- uses: Swatinem/rust-cache@v1
- name: Build
shell: bash
run: just build-android
# TODO: Additional clippy checks for different targets
- name: Check x86_64
shell: bash
run: |
env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \
env "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" \
just check maplibre-android x86_64-linux-android
- name: Check aarch64
shell: bash
run: |
env "AR_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \
env "CC_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang" \
just check maplibre-android aarch64-linux-android
# FIXME: Requires cross-compilation
#- name: Test
# shell: bash
# # TODO: Additional test runs for different targets
# run: just test maplibre-android aarch64-linux-android

View File

@ -1,42 +0,0 @@
name: macOS
description: Build for macOS
inputs:
GITHUB_TOKEN:
required: true
description: On macos runners we often hit API limits. Using this token avoid this.
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build
shell: bash
run: just xcodebuild-xcframework
- name: Check x86_64 darwin
shell: bash
run: just check apple x86_64-apple-darwin
- name: Check x86_64 darwin
shell: bash
# TODO: Additional clippy checks for different targets (iOS)
run: just check apple x86_64-apple-darwin
- name: Test x86_64 darwin
shell: bash
# TODO: Additional test runs for different targets (Different targets might require emulation)
run: just test apple x86_64-apple-darwin
- name: Build Example
shell: bash
run: cd apple/xcode && xcodebuild -scheme "example (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO
- name: Build Swift Package (arm64)
shell: bash
run: cd apple/MapLibreRs && swift build --arch=arm64
- name: Build Swift Package (x86_64)
shell: bash
run: cd apple/MapLibreRs && swift build --arch=x86_64

View File

@ -1,17 +0,0 @@
name: benchmarks
description: Run benchmarks
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Check
shell: bash
run: just check benchmarks x86_64-unknown-linux-gnu

View File

@ -1,14 +0,0 @@
name: check
description: Check
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Format
shell: bash
run: just fmt-check

View File

@ -1,27 +0,0 @@
name: linux-demo
description: Build linux-demo for linux
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
shell: bash
run: cargo build -p maplibre-demo
- name: Check
shell: bash
run: just check maplibre-demo x86_64-unknown-linux-gnu
- name: Test x86_64 linux
shell: bash
run: just test maplibre-demo x86_64-unknown-linux-gnu
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs
path: target/x86_64-unknown-linux-gnu/debug/maplibre-demo

View File

@ -1,32 +0,0 @@
name: macOS
description: Build for macOS
inputs:
GITHUB_TOKEN:
required: true
description: On macos runners we often hit API limits. Using this token avoid this.
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build
shell: bash
run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build
- name: Check x86_64 darwin
shell: bash
run: just check maplibre-demo x86_64-apple-darwin
- name: Test x86_64 darwin
shell: bash
run: just test maplibre-demo x86_64-apple-darwin
- uses: actions/upload-artifact@v3
with:
name: maplibre-x86_64-apple-darwin-demo
path: apple/xcode/build/Build/Products/Debug/*.app
if-no-files-found: error

View File

@ -1,35 +0,0 @@
name: windows-demo
description: Build windows-demo for windows
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe
- name: Install SQLite
shell: powershell
run: choco install sqlite -y --params "/NoTools"
- name: Build SQLite lib
shell: powershell
run: |
cd "C:\ProgramData\chocolatey\lib\SQLite\tools"
lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $env:GITHUB_ENV
- name: Build
shell: bash
run: cargo build -p maplibre-demo --release --target x86_64-pc-windows-msvc
- name: Check x86_64 windows
shell: bash
run: just check maplibre-demo x86_64-pc-windows-msvc
- name: Test x86_64 windows
shell: bash
run: just test maplibre-demo x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v3
with:
name: maplibre-x86_64-windows-demo
path: target/x86_64-pc-windows-msvc/release/maplibre-demo.exe
if-no-files-found: error

View File

@ -1,23 +0,0 @@
name: docs
description: Build documentation
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
working-directory: docs
shell: bash
run: mdbook build
- name: API Documentation
shell: bash
run: cargo doc -p maplibre --no-deps --lib --document-private-items

View File

@ -1,18 +0,0 @@
name: tests
description: Run tests
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Test
shell: bash
# TODO: Additional test runs for different targets
run: just test maplibre x86_64-unknown-linux-gnu

View File

@ -1,25 +0,0 @@
name: webgl
description: Build for webgl
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build lib
shell: bash
run: just web-lib esbuild-webgl
- name: Build demo
shell: bash
run: just web-demo build
- name: Check
shell: bash
run: just check web wasm32-unknown-unknown
- name: Test
shell: bash
run: |
cargo install wasm-bindgen-cli --version "0.2.80"
just web-test "web-webgl"

View File

@ -1,25 +0,0 @@
name: webgpu
description: Build for webgpu
runs:
using: "composite"
steps:
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build lib
shell: bash
run: just web-lib esbuild
- name: Build demo
shell: bash
run: just web-demo build
- name: Check
shell: bash
run: just check web wasm32-unknown-unknown
- name: Test
shell: bash
run: |
cargo install wasm-bindgen-cli --version "0.2.80"
just web-test ""

66
.github/workflows/build-deploy-docs.yml vendored Normal file
View File

@ -0,0 +1,66 @@
name: Build documentation
on:
workflow_call:
secrets:
SSH_KEY_MAXAMMANN_ORG:
required: false
inputs:
deploy:
required: true
type: boolean
jobs:
build-docs:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
working-directory: docs
shell: bash
run: mdbook build
- name: API Documentation
shell: bash
run: cargo doc -p maplibre --no-deps --lib --document-private-items
- uses: actions/upload-artifact@v2
with:
name: api-docs
path: target/doc/
- uses: actions/upload-artifact@v2
with:
name: book
path: docs/book/
deploy-docs:
needs: build-docs
if: inputs.deploy
name: Deploy
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v2
with:
name: api-docs
- uses: actions/download-artifact@v2
with:
name: book
- uses: ./.github/actions/deploy
with:
source: .
destination: api-docs
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
- uses: ./.github/actions/deploy
with:
source: .
destination: docs
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}

32
.github/workflows/demo-linux.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Build demo for Linux
on:
workflow_call:
jobs:
demo-linux:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
shell: bash
run: cargo build -p maplibre-demo
- name: Check
shell: bash
run: just check maplibre-demo x86_64-unknown-linux-gnu
- name: Test x86_64 linux
shell: bash
run: just test maplibre-demo x86_64-unknown-linux-gnu
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs
path: target/x86_64-unknown-linux-gnu/debug/maplibre-demo

32
.github/workflows/demo-macos.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Build demo for macOS
on:
workflow_call:
jobs:
demo-macos:
name: Build
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build
shell: bash
run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build
- name: Check x86_64 darwin
shell: bash
run: just check maplibre-demo x86_64-apple-darwin
- name: Test x86_64 darwin
shell: bash
run: just test maplibre-demo x86_64-apple-darwin
- uses: actions/upload-artifact@v3
with:
name: maplibre-x86_64-apple-darwin-demo
path: apple/xcode/build/Build/Products/Debug/*.app
if-no-files-found: error

40
.github/workflows/demo-windows.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Build demo for Windows
on:
workflow_call:
jobs:
demo-windows:
name: Build
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe
- name: Install SQLite
shell: powershell
run: choco install sqlite -y --params "/NoTools"
- name: Build SQLite lib
shell: powershell
run: |
cd "C:\ProgramData\chocolatey\lib\SQLite\tools"
lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $env:GITHUB_ENV
- name: Build
shell: bash
run: cargo build -p maplibre-demo --release --target x86_64-pc-windows-msvc
- name: Check x86_64 windows
shell: bash
run: just check maplibre-demo x86_64-pc-windows-msvc
- name: Test x86_64 windows
shell: bash
run: just test maplibre-demo x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v3
with:
name: maplibre-x86_64-windows-demo
path: target/x86_64-pc-windows-msvc/release/maplibre-demo.exe
if-no-files-found: error

44
.github/workflows/library-android.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Build android library
on:
workflow_call:
jobs:
library-android:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: just nightly-toolchain-android
- uses: Swatinem/rust-cache@v1
- name: Set NDK Version
shell: bash
run: |
ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
ln -sfn $ANDROID_SDK_ROOT/ndk/23.2.8568313 $ANDROID_NDK_ROOT
- name: Build
shell: bash
run: just build-android
# TODO: Additional clippy checks for different targets
- name: Check x86_64
shell: bash
run: |
env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \
env "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" \
just check maplibre-android x86_64-linux-android
- name: Check aarch64
shell: bash
run: |
env "AR_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \
env "CC_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang" \
just check maplibre-android aarch64-linux-android
# FIXME: Requires cross-compilation
#- name: Test
# shell: bash
# # TODO: Additional test runs for different targets
# run: just test maplibre-android aarch64-linux-android

43
.github/workflows/library-apple.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Build apple library
on:
workflow_call:
jobs:
library-apple:
name: Build
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build
shell: bash
run: just xcodebuild-xcframework
- name: Check x86_64 darwin
shell: bash
run: just check apple x86_64-apple-darwin
- name: Check x86_64 darwin
shell: bash
# TODO: Additional clippy checks for different targets (iOS)
run: just check apple x86_64-apple-darwin
- name: Test x86_64 darwin
shell: bash
# TODO: Additional test runs for different targets (Different targets might require emulation)
run: just test apple x86_64-apple-darwin
- name: Build Example
shell: bash
run: cd apple/xcode && xcodebuild -scheme "example (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO
- name: Build Swift Package (arm64)
shell: bash
run: cd apple/MapLibreRs && swift build --arch=arm64
- name: Build Swift Package (x86_64)
shell: bash
run: cd apple/MapLibreRs && swift build --arch=x86_64

84
.github/workflows/library-web.yml vendored Normal file
View File

@ -0,0 +1,84 @@
name: Build library for WebGL
on:
workflow_call:
secrets:
SSH_KEY_MAXAMMANN_ORG:
required: false
inputs:
deploy:
required: true
type: boolean
webgl:
required: true
type: boolean
jobs:
library-web:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
- name: Build lib
if: inputs.webgl
shell: bash
run: just web-lib esbuild-webgl
- name: Build lib
if: "!inputs.webgl"
shell: bash
run: just web-lib esbuild
- name: Build demo
shell: bash
run: just web-demo build
- name: Check
if: inputs.webgl
shell: bash
run: just web-check "web-webgl"
- name: Check
if: "!inputs.webgl"
shell: bash
run: just web-check ""
- name: Test
if: inputs.webgl
shell: bash
run: |
cargo install wasm-bindgen-cli --version "0.2.80"
just web-test "web-webgl"
- name: Test
if: "!inputs.webgl"
shell: bash
run: |
cargo install wasm-bindgen-cli --version "0.2.80"
just web-test ""
- uses: actions/upload-artifact@v2
with:
name: webgpu-demo
path: web/demo/dist/
deploy:
needs: library-web
if: inputs.deploy
name: Deploy
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v2
with:
name: webgpu-demo
- name: Deploy
if: "!inputs.webgl"
uses: ./.github/actions/deploy
with:
source: .
destination: webgl
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
- name: Deploy
if: "!inputs.webgl"
uses: ./.github/actions/deploy
with:
source: .
destination: webgpu
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}

View File

@ -8,82 +8,37 @@ on:
jobs: jobs:
run-check: run-check:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-checks.yml
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/check
run-benchmarks: run-benchmarks:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-benchmarks.yml
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/benchmarks
run-tests: run-tests:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-tests.yml
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/tests
build-android:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/android
build-deploy-webgpu:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/webgpu
- uses: ./.github/actions/deploy
with:
source: web/demo/dist/.
destination: webgpu
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
build-deploy-webgl:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/webgl
- uses: ./.github/actions/deploy
with:
source: web/demo/dist/.
destination: webgl
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
build-deploy-docs: build-deploy-docs:
runs-on: ubuntu-20.04 uses: ./.github/workflows/build-deploy-docs.yml
steps: with:
- uses: actions/checkout@v2 deploy: true
- uses: ./.github/actions/docs secrets: inherit
- uses: ./.github/actions/deploy library-android:
with: uses: ./.github/workflows/library-android.yml
source: target/doc/. library-webgpu:
destination: api-docs uses: ./.github/workflows/library-web.yml
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} with:
- uses: ./.github/actions/deploy deploy: true
with: webgl: false
source: docs/book/. secrets: inherit
destination: docs library-webgl:
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} uses: ./.github/workflows/library-web.yml
build-apple: with:
runs-on: macos-11 deploy: true
steps: webgl: true
- uses: actions/checkout@v2 secrets: inherit
- uses: ./.github/actions/apple library-apple:
with: uses: ./.github/workflows/library-apple.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} demo-linux:
build-demo-linux: uses: ./.github/workflows/demo-linux.yml
runs-on: ubuntu-20.04 demo-windows:
steps: uses: ./.github/workflows/demo-windows.yml
- uses: actions/checkout@v2 demo-macos:
- uses: ./.github/actions/demo/linux uses: ./.github/workflows/demo-macos.yml
build-demo-windows: secrets: inherit
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/demo/windows
build-demo-macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/demo/macos
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -8,61 +8,33 @@ on:
jobs: jobs:
run-check: run-check:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-checks.yml
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/check
run-benchmarks: run-benchmarks:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-benchmarks.yml
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/benchmarks
run-tests: run-tests:
runs-on: ubuntu-20.04 uses: ./.github/workflows/run-tests.yml
steps: build-deploy-docs:
- uses: actions/checkout@v2 uses: ./.github/workflows/build-deploy-docs.yml
- uses: ./.github/actions/tests with:
build-android: deploy: false
runs-on: ubuntu-20.04 library-android:
steps: uses: ./.github/workflows/library-android.yml
- uses: actions/checkout@v2 library-webgpu:
- uses: ./.github/actions/android uses: ./.github/workflows/library-web.yml
build-webgpu: with:
runs-on: ubuntu-20.04 deploy: false
steps: webgl: false
- uses: actions/checkout@v2 library-webgl:
- uses: ./.github/actions/webgpu uses: ./.github/workflows/library-web.yml
build-webgl: with:
runs-on: ubuntu-20.04 deploy: false
steps: webgl: true
- uses: actions/checkout@v2 library-apple:
- uses: ./.github/actions/webgl uses: ./.github/workflows/library-apple.yml
build-docs: demo-linux:
runs-on: ubuntu-20.04 uses: ./.github/workflows/demo-linux.yml
steps: demo-windows:
- uses: actions/checkout@v2 uses: ./.github/workflows/demo-windows.yml
- uses: ./.github/actions/docs demo-macos:
build-apple: uses: ./.github/workflows/demo-macos.yml
runs-on: macos-11 secrets: inherit
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/apple
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-demo-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/demo/linux
build-demo-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/demo/windows
build-demo-macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/demo/macos
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

22
.github/workflows/run-benchmarks.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Run benchmarks
on:
workflow_call:
jobs:
run-benchmarks:
name: Benchmark
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Check
shell: bash
run: just check benchmarks x86_64-unknown-linux-gnu

19
.github/workflows/run-checks.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Run checks
on:
workflow_call:
jobs:
run-checks:
name: Check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Format
shell: bash
run: just fmt-check

34
.github/workflows/run-tests.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Run tests of "maplibre"
on:
workflow_call:
jobs:
run-tests:
name: Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Mesa Dependencies
shell: bash
run: sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: wgpu info
shell: bash
run: |
cargo install --git "https://github.com/gfx-rs/wgpu" wgpu-info
wgpu-info
- name: Test Vulkan
shell: bash
# TODO: Additional test runs for different targets
run: |
WGPU_BACKEND=vulkan just test maplibre x86_64-unknown-linux-gnu
- name: Test EGL
shell: bash
# TODO: Additional test runs for different targets
run: |
EGL_LOG_LEVEL=debug WGPU_BACKEND=gl just test maplibre x86_64-unknown-linux-gnu

View File

@ -7,7 +7,7 @@ plugins {
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
android { android {
ndkVersion "23.1.7779620" ndkVersion "23.2.8568313"
compileSdkVersion 29 compileSdkVersion 29

View File

@ -5,10 +5,15 @@
set shell := ["bash", "-c"] set shell := ["bash", "-c"]
export NIGHTLY_TOOLCHAIN := "nightly-2022-04-04-x86_64-unknown-linux-gnu" export NIGHTLY_TOOLCHAIN := "nightly-2022-04-04-x86_64-unknown-linux-gnu"
export CARGO_TERM_COLOR := "always"
export RUST_BACKTRACE := "1"
install-clippy: install-clippy:
rustup component add clippy rustup component add clippy
install-nightly-clippy:
rustup component add clippy --toolchain $NIGHTLY_TOOLCHAIN
check PROJECT ARCH: install-clippy check PROJECT ARCH: install-clippy
cargo clippy --no-deps -p {{PROJECT}} --target {{ARCH}} cargo clippy --no-deps -p {{PROJECT}} --target {{ARCH}}
@ -45,6 +50,9 @@ web-lib TARGET: nightly-toolchain (web-install "lib")
web-demo TARGET: (web-install "demo") web-demo TARGET: (web-install "demo")
cd web/demo && npm run {{TARGET}} cd web/demo && npm run {{TARGET}}
web-check FEATURES: nightly-toolchain install-nightly-clippy
export RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN && cargo clippy --no-deps -p web --features "{{FEATURES}}" --target wasm32-unknown-unknown -Z build-std=std,panic_abort
web-test FEATURES: nightly-toolchain web-test FEATURES: nightly-toolchain
export RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN && cargo test -p web --features "{{FEATURES}}" --target wasm32-unknown-unknown -Z build-std=std,panic_abort export RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN && cargo test -p web --features "{{FEATURES}}" --target wasm32-unknown-unknown -Z build-std=std,panic_abort

View File

@ -12,7 +12,7 @@ readme = "../README.md"
sqlite = ["rusqlite"] sqlite = ["rusqlite"]
[dependencies] [dependencies]
naga = { version = "0.8", features = ["wgsl-in"] } naga = { git = "https://github.com/gfx-rs/naga", branch = "master", features = ["wgsl-in"] }
walkdir = "2.3" walkdir = "2.3"
log = "0.4" log = "0.4"
rusqlite = {version= "0.26", optional=true} rusqlite = {version= "0.26", optional=true}

View File

@ -4,7 +4,7 @@ use std::process::exit;
use naga::front::wgsl; use naga::front::wgsl;
use naga::valid::{Capabilities, ValidationFlags, Validator}; use naga::valid::{Capabilities, ValidationFlags, Validator};
use naga::{front::wgsl::ParseError, valid::ValidationError}; use naga::{front::wgsl::ParseError, valid::ValidationError, SourceLocation};
use walkdir::WalkDir; use walkdir::WalkDir;
#[derive(Debug)] #[derive(Debug)]
@ -12,8 +12,7 @@ pub enum WgslError {
ValidationErr(ValidationError), ValidationErr(ValidationError),
ParserErr { ParserErr {
error: String, error: String,
line: usize, location: Option<SourceLocation>,
pos: usize,
}, },
IoErr(std::io::Error), IoErr(std::io::Error),
} }
@ -26,9 +25,9 @@ impl From<std::io::Error> for WgslError {
impl WgslError { impl WgslError {
pub fn from_parse_err(err: ParseError, src: &str) -> Self { pub fn from_parse_err(err: ParseError, src: &str) -> Self {
let (line, pos) = err.location(src); let location = err.location(src);
let error = err.emit_to_string(src); let error = err.emit_to_string(src);
Self::ParserErr { error, line, pos } Self::ParserErr { error, location }
} }
} }
@ -72,8 +71,17 @@ pub fn validate_project_wgsl() {
path.to_str().unwrap(), path.to_str().unwrap(),
match err { match err {
WgslError::ValidationErr(error) => format!(": {:?}", error), WgslError::ValidationErr(error) => format!(": {:?}", error),
WgslError::ParserErr { error, line, pos } => WgslError::ParserErr { error, location } =>
format!(":{}:{} {}", line, pos, error), if let Some(SourceLocation {
line_number,
line_position,
..
}) = location
{
format!(":{}:{} {}", line_number, line_position, error)
} else {
format!("{}", error)
},
WgslError::IoErr(error) => format!(": {:?}", error), WgslError::IoErr(error) => format!(": {:?}", error),
} }
); );

View File

@ -50,7 +50,9 @@ geozero = { version = "0.9.4", default-features = false, features = ["with-mvt",
tile-grid = "0.3" tile-grid = "0.3"
# Rendering # Rendering
wgpu = { version = "0.12" } wgpu = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
wgpu-hal = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
lyon = { version = "0.17", features = [] } lyon = { version = "0.17", features = [] }
raw-window-handle = "0.4" raw-window-handle = "0.4"

View File

@ -384,6 +384,7 @@ mod tests {
use crate::render::graph_runner::RenderGraphRunner; use crate::render::graph_runner::RenderGraphRunner;
use crate::render::resource::Surface; use crate::render::resource::Surface;
use crate::{MapWindow, MapWindowConfig, RenderState, Renderer, RendererSettings, WindowSize}; use crate::{MapWindow, MapWindowConfig, RenderState, Renderer, RendererSettings, WindowSize};
use log::LevelFilter;
pub struct HeadlessMapWindowConfig { pub struct HeadlessMapWindowConfig {
size: WindowSize, size: WindowSize,
@ -409,18 +410,16 @@ mod tests {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
#[tokio::test] #[tokio::test]
#[ignore] // FIXME: We do not have a GPU in CI
async fn test_render() { async fn test_render() {
let _ = env_logger::builder()
.filter_level(LevelFilter::Trace)
.is_test(true)
.try_init();
let graph = RenderGraph::default(); let graph = RenderGraph::default();
let instance = wgpu::Instance::new(wgpu::Backends::all()); let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all());
let instance = wgpu::Instance::new(backends);
let adapter = instance let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, backends, None)
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: Default::default(),
force_fallback_adapter: false,
compatible_surface: None,
})
.await .await
.unwrap(); .unwrap();

View File

@ -71,42 +71,40 @@ impl BufferedTextureHead {
) { ) {
// Note that we're not calling `.await` here. // Note that we're not calling `.await` here.
let buffer_slice = self.output_buffer.slice(..); let buffer_slice = self.output_buffer.slice(..);
let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read); let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read, |_| ());
// Poll the device in a blocking manner so that our future resolves. // Poll the device in a blocking manner so that our future resolves.
// In an actual application, `device.poll(...)` should // In an actual application, `device.poll(...)` should
// be called in an event loop or on another thread. // be called in an event loop or on another thread.
device.poll(wgpu::Maintain::Wait); device.poll(wgpu::Maintain::Wait);
if let Ok(()) = buffer_future.await { let padded_buffer = buffer_slice.get_mapped_range();
let padded_buffer = buffer_slice.get_mapped_range();
let mut png_encoder = png::Encoder::new( let mut png_encoder = png::Encoder::new(
File::create(png_output_path).unwrap(), File::create(png_output_path).unwrap(),
self.buffer_dimensions.width as u32, self.buffer_dimensions.width as u32,
self.buffer_dimensions.height as u32, self.buffer_dimensions.height as u32,
); );
png_encoder.set_depth(png::BitDepth::Eight); png_encoder.set_depth(png::BitDepth::Eight);
png_encoder.set_color(png::ColorType::Rgba); png_encoder.set_color(png::ColorType::Rgba);
let mut png_writer = png_encoder let mut png_writer = png_encoder
.write_header() .write_header()
.unwrap() .unwrap()
.into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row) .into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row)
.unwrap();
// from the padded_buffer we write just the unpadded bytes into the image
for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) {
png_writer
.write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row])
.unwrap(); .unwrap();
// from the padded_buffer we write just the unpadded bytes into the image
for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) {
png_writer
.write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row])
.unwrap();
}
png_writer.finish().unwrap();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(padded_buffer);
self.output_buffer.unmap();
} }
png_writer.finish().unwrap();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(padded_buffer);
self.output_buffer.unmap();
} }
} }

View File

@ -1,8 +1,8 @@
struct Output { struct Output {
[[location(0)]] out_color: vec4<f32>; @location(0) out_color: vec4<f32>,
}; };
[[stage(fragment)]] @fragment
fn main([[location(0)]] v_color: vec4<f32>) -> Output { fn main(@location(0) v_color: vec4<f32>) -> Output {
return Output(v_color); return Output(v_color);
} }

View File

@ -1,31 +1,31 @@
struct ShaderCamera { struct ShaderCamera {
view_proj: mat4x4<f32>; view_proj: mat4x4<f32>,
view_position: vec4<f32>; view_position: vec4<f32>,
}; };
struct ShaderGlobals { struct ShaderGlobals {
camera: ShaderCamera; camera: ShaderCamera,
}; };
[[group(0), binding(0)]] var<uniform> globals: ShaderGlobals; @group(0) @binding(0) var<uniform> globals: ShaderGlobals;
struct VertexOutput { struct VertexOutput {
[[location(0)]] v_color: vec4<f32>; @location(0) v_color: vec4<f32>,
[[builtin(position)]] position: vec4<f32>; @builtin(position) position: vec4<f32>,
}; };
[[stage(vertex)]] @vertex
fn main( fn main(
[[location(0)]] position: vec2<f32>, @location(0) position: vec2<f32>,
[[location(1)]] normal: vec2<f32>, @location(1) normal: vec2<f32>,
[[location(4)]] translate1: vec4<f32>, @location(4) translate1: vec4<f32>,
[[location(5)]] translate2: vec4<f32>, @location(5) translate2: vec4<f32>,
[[location(6)]] translate3: vec4<f32>, @location(6) translate3: vec4<f32>,
[[location(7)]] translate4: vec4<f32>, @location(7) translate4: vec4<f32>,
[[location(8)]] color: vec4<f32>, @location(8) color: vec4<f32>,
[[location(9)]] zoom_factor: f32, @location(9) zoom_factor: f32,
[[location(10)]] z_index: f32, @location(10) z_index: f32,
[[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" @builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
) -> VertexOutput { ) -> VertexOutput {
let z = 0.0; let z = 0.0;
let width = 3.0 * zoom_factor; let width = 3.0 * zoom_factor;

View File

@ -1,8 +1,8 @@
struct Output { struct Output {
[[location(0)]] out_color: vec4<f32>; @location(0) out_color: vec4<f32>,
}; };
[[stage(fragment)]] @fragment
fn main([[location(0)]] v_color: vec4<f32>) -> Output { fn main(@location(0) v_color: vec4<f32>) -> Output {
return Output(v_color); return Output(v_color);
} }

View File

@ -1,29 +1,29 @@
struct ShaderCamera { struct ShaderCamera {
view_proj: mat4x4<f32>; view_proj: mat4x4<f32>,
view_position: vec4<f32>; view_position: vec4<f32>,
}; };
struct ShaderGlobal { struct ShaderGlobal {
camera: ShaderCamera; camera: ShaderCamera,
}; };
[[group(0), binding(0)]] var<uniform> globals: ShaderGlobal; @group(0) @binding(0) var<uniform> globals: ShaderGlobal;
struct VertexOutput { struct VertexOutput {
[[location(0)]] v_color: vec4<f32>; @location(0) v_color: vec4<f32>,
[[builtin(position)]] position: vec4<f32>; @builtin(position) position: vec4<f32>,
}; };
let EXTENT = 4096.0; let EXTENT = 4096.0;
[[stage(vertex)]] @vertex
fn main( fn main(
[[location(4)]] translate1: vec4<f32>, @location(4) translate1: vec4<f32>,
[[location(5)]] translate2: vec4<f32>, @location(5) translate2: vec4<f32>,
[[location(6)]] translate3: vec4<f32>, @location(6) translate3: vec4<f32>,
[[location(7)]] translate4: vec4<f32>, @location(7) translate4: vec4<f32>,
[[builtin(vertex_index)]] vertex_idx: u32, @builtin(vertex_index) vertex_idx: u32,
[[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" @builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
) -> VertexOutput { ) -> VertexOutput {
let z = 0.0; let z = 0.0;