From a898b9eb2d6936278951a64bc1f53a0009820e95 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Fri, 11 Feb 2022 09:44:38 +0300 Subject: [PATCH] use Rust svdtools + cache --- .github/bors.toml | 19 +--------- .github/workflows/ci.yaml | 58 +++++++++++++++++------------ .github/workflows/mmaps_master.yaml | 26 ++++++++++--- .github/workflows/mmaps_pr.yaml | 27 +++++++++++--- .github/workflows/nightlies.yaml | 54 +++++++++++++-------------- CHANGELOG.md | 1 + 6 files changed, 105 insertions(+), 80 deletions(-) diff --git a/.github/bors.toml b/.github/bors.toml index 8f8a3b6aa..91f7b2dab 100644 --- a/.github/bors.toml +++ b/.github/bors.toml @@ -1,21 +1,4 @@ required_approvals = 1 block_labels = ["wip"] delete_merged_branches = true -status = [ - "Check (stm32f0)", - "Check (stm32f1)", - "Check (stm32f2)", - "Check (stm32f3)", - "Check (stm32f4)", - "Check (stm32f7)", - "Check (stm32h7)", - "Check (stm32l0)", - "Check (stm32l1)", - "Check (stm32l4)", - "Check (stm32l5)", - "Check (stm32g0)", - "Check (stm32g4)", - "Check (stm32mp1)", - "Check (stm32wl)", - "Check (stm32wb)", -] +status = ["CI"] diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7cf2326ee..b9c083e44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,24 @@ name: CI +env: + SVDTOOLS_VERSION: 0.2.1 + SVD2RUST_VERSION: 0.21.0 + FORM_VERSION: 0.8.0 + on: push: branches: [ staging, trying, master ] pull_request: jobs: + ci: + name: CI + runs-on: ubuntu-latest + needs: [check] + steps: + - name: Done + run: exit 0 + check: name: Check runs-on: ubuntu-latest @@ -28,12 +41,16 @@ jobs: - stm32mp1 - stm32wl - stm32wb + env: CRATES: ${{ matrix.crate }} CARGO_INCREMENTAL: 0 + SVDTOOLS: svdtools + steps: - name: Checkout code uses: actions/checkout@v2 + - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -41,38 +58,33 @@ jobs: profile: minimal override: true components: rustfmt + - name: Install xmllint run: sudo apt-get install libxml2-utils - - name: Install Python dependencies - run: | - pip3 install --user setuptools wheel - pip3 install --user svdtools - - name: Put pip binary directory into path - run: echo "~/.local/bin" >> $GITHUB_PATH - - name: Cache Cargo installed binaries - uses: actions/cache@v1 - id: cache-cargo - with: - path: ~/cargo-bin - key: ${{ runner.os }}-svd2rust-0.21.0 - - name: Install svd2rust - if: steps.cache-cargo.outputs.cache-hit != 'true' - uses: actions-rs/install@v0.1 + + - name: Create working crate + run: make crates + + - name: Cache dependencies + uses: Swatinem/rust-cache@v1 with: - crate: svd2rust - version: 0.21.0 - - name: Copy svd2rust to cache directory - if: steps.cache-cargo.outputs.cache-hit != 'true' + working-directory: ${{ matrix.crate }} + key: svdtools-${{ env.SVDTOOLS_VERSION }}-svd2rust-${{ env.SVD2RUST_VERSION }}-form-${{ env.FORM_VERSION }} + + - name: Install tools run: | - mkdir ~/cargo-bin - cp ~/.cargo/bin/svd2rust ~/cargo-bin - - name: Put new cargo binary directory into path - run: echo "~/cargo-bin" >> $GITHUB_PATH + cargo install svdtools --version $SVDTOOLS_VERSION --target-dir deps-target + cargo install svd2rust --version $SVD2RUST_VERSION --target-dir deps-target + cargo install form --version $FORM_VERSION --target-dir deps-target + - name: Patch SVDs run: make -j2 patch + - name: Check SVDs run: make lint + - name: Build PACs run: make -j2 svd2rust + - name: Check PACs run: make -j2 check diff --git a/.github/workflows/mmaps_master.yaml b/.github/workflows/mmaps_master.yaml index 5ead280fc..199f75652 100644 --- a/.github/workflows/mmaps_master.yaml +++ b/.github/workflows/mmaps_master.yaml @@ -1,5 +1,8 @@ name: build mmaps +env: + SVDTOOLS_VERSION: 0.2.1 + on: push: branches: @@ -9,23 +12,36 @@ jobs: build: name: Build mmaps runs-on: ubuntu-18.04 + + env: + SVDTOOLS: svdtools + steps: - name: Checkout stm32-rs uses: actions/checkout@v2 with: path: stm32-rs + - name: Checkout mmaps uses: actions/checkout@v2 with: repository: stm32-rs/stm32-rs-mmaps ssh-key: ${{ secrets.MMAPS_KEY }} path: stm32-rs-mmaps - - name: Install Python dependencies + + - name: Add fictive crate run: | - pip3 install --user setuptools wheel - pip3 install --user svdtools - - name: Put pip binary directory into path - run: echo "~/.local/bin" >> $GITHUB_PATH + cargo init + + - name: Cache dependencies + uses: Swatinem/rust-cache@v1 + with: + key: svdtools-${{ env.SVDTOOLS_VERSION }} + + - name: Install svdtools + run: | + cargo install svdtools --version $SVDTOOLS_VERSION + - name: Build and publish run: | cd stm32-rs diff --git a/.github/workflows/mmaps_pr.yaml b/.github/workflows/mmaps_pr.yaml index b428404d6..e6402d269 100644 --- a/.github/workflows/mmaps_pr.yaml +++ b/.github/workflows/mmaps_pr.yaml @@ -1,5 +1,8 @@ name: compare mmaps +env: + SVDTOOLS_VERSION: 0.2.1 + on: pull_request_target: @@ -8,28 +11,42 @@ jobs: name: Compare mmaps runs-on: ubuntu-18.04 continue-on-error: true + + env: + SVDTOOLS: svdtools + steps: - name: Checkout master uses: actions/checkout@v2 with: path: master + - name: Checkout pull request uses: actions/checkout@v2 with: ref: refs/pull/${{ github.event.number }}/head path: pr + - name: Checkout mmaps uses: actions/checkout@v2 with: repository: stm32-rs/stm32-rs-mmaps ssh-key: ${{ secrets.MMAPS_KEY }} path: mmaps - - name: Install Python dependencies + + - name: Add fictive crate run: | - pip3 install --user setuptools wheel - pip3 install --user svdtools - - name: Put pip binary directory into path - run: echo "~/.local/bin" >> $GITHUB_PATH + cargo init + + - name: Cache dependencies + uses: Swatinem/rust-cache@v1 + with: + key: svdtools-${{ env.SVDTOOLS_VERSION }} + + - name: Install svdtools + run: | + cargo install svdtools --version $SVDTOOLS_VERSION + - name: Build and publish run: | # Grab commit ID from checked out PR diff --git a/.github/workflows/nightlies.yaml b/.github/workflows/nightlies.yaml index 0a7b4ca90..1cc506af7 100644 --- a/.github/workflows/nightlies.yaml +++ b/.github/workflows/nightlies.yaml @@ -1,4 +1,10 @@ name: build nightlies + +env: + SVDTOOLS_VERSION: 0.2.1 + SVD2RUST_VERSION: 0.21.0 + FORM_VERSION: 0.8.0 + on: push: branches: @@ -8,17 +14,16 @@ jobs: build: name: Build runs-on: ubuntu-18.04 + + env: + SVDTOOLS: svdtools + steps: - name: Checkout master uses: actions/checkout@v2 with: path: stm32-rs - - name: Install Python dependencies - run: | - pip3 install --user setuptools wheel - pip3 install --user svdtools - - name: Put pip binary directory into path - run: echo "~/.local/bin" >> $GITHUB_PATH + - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -26,31 +31,22 @@ jobs: profile: minimal components: rustfmt override: true - - name: Cache Cargo installed binaries - uses: actions/cache@v1 - id: cache-cargo - with: - path: ~/cargo-bin - key: ${{ runner.os }}-cargo-binaries-0.18.0 - - name: Install svd2rust - if: steps.cache-cargo.outputs.cache-hit != 'true' - uses: actions-rs/cargo@v1 - with: - command: install - args: svd2rust --version 0.21.0 - - name: Install form - if: steps.cache-cargo.outputs.cache-hit != 'true' - uses: actions-rs/cargo@v1 + + - name: Add fictive crate + run: | + cargo init + + - name: Cache dependencies + uses: Swatinem/rust-cache@v1 with: - command: install - args: form --version 0.7.0 - - name: Copy svd2rust and form to cache directory - if: steps.cache-cargo.outputs.cache-hit != 'true' + key: svdtools-${{ env.SVDTOOLS_VERSION }}-svd2tust-${{ env.SVD2RUST_VERSION }}-form-${{ env.FORM_VERSION }} + + - name: Install dependencies run: | - mkdir ~/cargo-bin - cp ~/.cargo/bin/{svd2rust,form} ~/cargo-bin - - name: Put cargo binary directory into path - run: echo "~/cargo-bin" >> $GITHUB_PATH + cargo install svdtools --version $SVDTOOLS_VERSION --target-dir deps-target + cargo install svd2rust --version $SVD2RUST_VERSION --target-dir deps-target + cargo install form --version $FORM_VERSION --target-dir deps-target + - name: Deploy SSH key run: | mkdir ~/.ssh diff --git a/CHANGELOG.md b/CHANGELOG.md index 435a24fb9..25515fa55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +* Replace python svd tools with rust alternatives * Updated to svd2rust 0.21 * `SVDTOOLS` env value for specifying patching tool