From 33f48a0a1ba0b173c3e9da232e150fd1ffe3a688 Mon Sep 17 00:00:00 2001 From: Maximilian Ammann Date: Wed, 20 Apr 2022 14:55:29 +0200 Subject: [PATCH] Use composite actions --- .github/actions/android/action.yml | 26 +++++++++++++++ .github/actions/check/action.yml | 21 ++++++++++++ .github/actions/deploy/action.yml | 26 +++++++++++++++ .github/actions/desktop/action.yml | 26 +++++++++++++++ .github/actions/docs/action.yml | 30 +++++++++++++++++ .github/actions/webgl/action.yml | 22 +++++++++++++ .github/actions/webgpu/action.yml | 22 +++++++++++++ .github/workflows/android.yml | 32 ------------------ .github/workflows/check.yml | 23 ------------- .github/workflows/deploy.yml | 22 ------------- .github/workflows/desktop.yml | 32 ------------------ .github/workflows/docs.yml | 32 ------------------ .github/workflows/on_main_push.yml | 47 +++++++++++++++++---------- .github/workflows/on_pull_request.yml | 23 +++++++++---- .github/workflows/webgl.yml | 29 ----------------- .github/workflows/webgpu.yml | 30 ----------------- 16 files changed, 219 insertions(+), 224 deletions(-) create mode 100644 .github/actions/android/action.yml create mode 100644 .github/actions/check/action.yml create mode 100644 .github/actions/deploy/action.yml create mode 100644 .github/actions/desktop/action.yml create mode 100644 .github/actions/docs/action.yml create mode 100644 .github/actions/webgl/action.yml create mode 100644 .github/actions/webgpu/action.yml delete mode 100644 .github/workflows/android.yml delete mode 100644 .github/workflows/check.yml delete mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/desktop.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/webgl.yml delete mode 100644 .github/workflows/webgpu.yml diff --git a/.github/actions/android/action.yml b/.github/actions/android/action.yml new file mode 100644 index 00000000..94483c97 --- /dev/null +++ b/.github/actions/android/action.yml @@ -0,0 +1,26 @@ +name: android +description: Build for android + +runs: + using: "composite" + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates* + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install just + shell: bash + run: cargo install just + - name: Build + shell: bash + run: just build-apk + - uses: actions/upload-artifact@v2 + with: + name: maplibre-rs.apk + path: target/debug/apk/maplibre-rs-demo.apk diff --git a/.github/actions/check/action.yml b/.github/actions/check/action.yml new file mode 100644 index 00000000..68ae9670 --- /dev/null +++ b/.github/actions/check/action.yml @@ -0,0 +1,21 @@ +name: check +description: Check + +runs: + using: "composite" + steps: + - name: Setup + shell: bash + run: | + rustup component add rustfmt + - name: Format + shell: bash + run: cargo fmt --all -- --check + - name: Install Dependencies + shell: bash + run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit + - name: Clippy + shell: bash + run: | + rustup component add clippy + cargo clippy --all-targets --all-features \ No newline at end of file diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml new file mode 100644 index 00000000..b3ebf267 --- /dev/null +++ b/.github/actions/deploy/action.yml @@ -0,0 +1,26 @@ +name: deploy +description: Deploy on maxammann.org + +inputs: + source: + required: true + description: TODO + destination: + required: true + description: TODO + key: + required: true + description: TODO + +runs: + using: "composite" + steps: + - name: Deploy to maxammann.org + env: + SSH_KEY: ${{ inputs.key }} + shell: bash + run: | + echo "$SSH_KEY" > id_rsa + chmod 600 id_rsa + ssh -o StrictHostKeyChecking=no -i id_rsa max@maxammann.org 'mkdir -p ~/public_html/maplibre-rs/${{ inputs.destination }} && find ~/public_html/maplibre-rs/${{ inputs.destination }} -type f -not -name ".htaccess" -delete' + rsync -e "ssh -o StrictHostKeyChecking=no -i id_rsa" -r "${{ inputs.source }}" max@maxammann.org:~/public_html/maplibre-rs/${{ inputs.destination }}/ diff --git a/.github/actions/desktop/action.yml b/.github/actions/desktop/action.yml new file mode 100644 index 00000000..4217d2b5 --- /dev/null +++ b/.github/actions/desktop/action.yml @@ -0,0 +1,26 @@ +name: desktop +description: Build for desktop + +runs: + using: "composite" + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates* + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - 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 --example desktop + - uses: actions/upload-artifact@v2 + with: + name: maplibre-rs + path: target/debug/maplibre \ No newline at end of file diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml new file mode 100644 index 00000000..0cbca8ea --- /dev/null +++ b/.github/actions/docs/action.yml @@ -0,0 +1,30 @@ +name: docs +description: Build documentation + +runs: + using: "composite" + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates* + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1 + - name: Install mdbook + shell: bash + run: | + cargo install mdbook --no-default-features --vers "^0.4.0" + - 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 --no-deps --workspace --lib --all-features --document-private-items diff --git a/.github/actions/webgl/action.yml b/.github/actions/webgl/action.yml new file mode 100644 index 00000000..f1946ace --- /dev/null +++ b/.github/actions/webgl/action.yml @@ -0,0 +1,22 @@ +name: webgl +description: Build for webgl + +runs: + using: "composite" + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates* + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install just + shell: bash + run: cargo install just + - name: Build + shell: bash + run: just webpack-webgl-production diff --git a/.github/actions/webgpu/action.yml b/.github/actions/webgpu/action.yml new file mode 100644 index 00000000..d08ddf78 --- /dev/null +++ b/.github/actions/webgpu/action.yml @@ -0,0 +1,22 @@ +name: webgpu +description: Build for webgpu + +runs: + using: "composite" + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/.crates* + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install just + shell: bash + run: cargo install just + - name: Build + shell: bash + run: just webpack-production diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index ee2ced83..00000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: android - -on: [ workflow_dispatch ] - -jobs: - build-aarch64-android: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates* - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install just - run: cargo install just - - name: Build - run: just build-apk - - uses: actions/upload-artifact@v2 - with: - name: maplibre-rs.apk - path: target/debug/apk/maplibre-rs-demo.apk diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index a593bef1..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: check - -on: [ workflow_dispatch ] - -jobs: - check-format: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Setup - run: | - rustup component add rustfmt - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: | - rustup component add clippy - cargo clippy --all-targets --all-features \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 16dc7ec9..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,22 +0,0 @@ -on: - workflow_call: - inputs: - source: - required: true - type: string - destination: - required: true - type: string - -jobs: - deploy: - runs-on: ubuntu-20.04 - steps: - - name: Deploy to maxammann.org - env: - SSH_KEY: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} - run: | - echo "$SSH_KEY" > id_rsa - chmod 600 id_rsa - ssh -o StrictHostKeyChecking=no -i id_rsa max@maxammann.org 'mkdir -p ~/public_html/maplibre-rs/${{ inputs.destination }} && find ~/public_html/maplibre-rs/${{ inputs.destination }} -type f -not -name ".htaccess" -delete' - rsync -e "ssh -o StrictHostKeyChecking=no -i id_rsa" -r "${{ inputs.source }}" max@maxammann.org:~/public_html/maplibre-rs/${{ inputs.destination }}/ diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml deleted file mode 100644 index 55d0d4ab..00000000 --- a/.github/workflows/desktop.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: desktop - -on: [ workflow_dispatch ] - -jobs: - build-x86: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates* - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install Dependencies - run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit - - name: Build - run: cargo build --example desktop - - uses: actions/upload-artifact@v2 - with: - name: maplibre-rs - path: target/debug/maplibre \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 36cff847..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: docs - -on: [ workflow_dispatch ] - -jobs: - book: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - working-directory: docs - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates* - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1 - - name: Install mdbook - run: | - cargo install mdbook --no-default-features --vers "^0.4.0" - - name: Build - run: mdbook build - - name: API Documentation - run: cargo doc --no-deps --workspace --lib --all-features --document-private-items diff --git a/.github/workflows/on_main_push.yml b/.github/workflows/on_main_push.yml index a00fc46d..6bc8491c 100644 --- a/.github/workflows/on_main_push.yml +++ b/.github/workflows/on_main_push.yml @@ -1,45 +1,58 @@ -name: Rust +name: Build & Deploy -on: [ workflow_dispatch, push ] +on: + workflow_dispatch: + push: + branches: + - main jobs: run-check: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/check.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/check build-desktop: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/desktop.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/desktop build-android: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/android.yml - build-web: + - uses: actions/checkout@v2 + - uses: ./.github/actions/android + build-deploy-web: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/webgpu.yml - - uses: ./.github/workflows/deploy.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/webgpu + - uses: ./.github/actions/deploy with: - source: dist/demo/. + source: web/dist/demo/. destination: webgpu - - uses: ./.github/workflows/webgl.yml - - uses: ./.github/workflows/deploy.yml + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + - uses: ./.github/actions/webgl + - uses: ./.github/actions/deploy with: - source: dist/demo/. + source: web/dist/demo/. destination: webgl - build-docs: + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + build-deploy-docs: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/docs.yml - - uses: ./.github/workflows/deploy.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/docs + - uses: ./.github/actions/deploy with: source: target/x86_64-unknown-linux-gnu/doc/. destination: api-docs - - uses: ./.github/workflows/deploy.yml + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + - uses: ./.github/actions/deploy with: - source: book/. + source: docs/book/. destination: docs + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index f6e302c7..0d4d99ae 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -1,26 +1,35 @@ name: Pull Request -on: [ workflow_dispatch, pull_request ] +on: + workflow_dispatch: + pull_request: + branches: + - main jobs: run-check: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/check.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/check build-desktop: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/desktop.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/desktop build-android: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/android.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/android build-web: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/webgpu.yml - - uses: ./.github/workflows/webgl.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/webgpu + - uses: ./.github/actions/webgl build-docs: runs-on: ubuntu-20.04 steps: - - uses: ./.github/workflows/docs.yml + - uses: actions/checkout@v2 + - uses: ./.github/actions/docs diff --git a/.github/workflows/webgl.yml b/.github/workflows/webgl.yml deleted file mode 100644 index 7583b584..00000000 --- a/.github/workflows/webgl.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: web - -on: [ workflow_dispatch ] - -jobs: - build-wasm-webgl: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - working-directory: web - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates* - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install just - run: cargo install just - - name: Build - run: just webpack-webgl-production diff --git a/.github/workflows/webgpu.yml b/.github/workflows/webgpu.yml deleted file mode 100644 index 4cab1d5b..00000000 --- a/.github/workflows/webgpu.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: web - -on: [ workflow_dispatch ] - -jobs: - - build-wasm-webgpu: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - working-directory: web - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/.crates* - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install just - run: cargo install just - - name: Build - run: just webpack-production