From 0c0ba851f3a8506299d0bf811c0808f5d4de66cd Mon Sep 17 00:00:00 2001 From: Rob Thijssen Date: Sat, 3 Jul 2021 22:15:55 +0200 Subject: [PATCH] snapr build/release ci --- .github/workflows/ci.yml | 181 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 86 ++++++++++++++++ .github/workflows/rust.yml | 63 ------------ 3 files changed, 267 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2ff13f5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,181 @@ +--- +# see: https://www.infinyon.com/blog/2021/04/github-actions-best-practices +name: ci +on: + pull_request: + push: + workflow_dispatch: +env: + CARGO_TERM_COLOR: always +jobs: + build: + name: build (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + include: + - os: ubuntu-latest + sccache-path: /home/runner/.cache/sccache + env: + RUST_BACKTRACE: full + RUSTC_WRAPPER: sccache + RUSTV: ${{ matrix.rust }} + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: ${{ matrix.sccache-path }} + # SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out + steps: + - uses: actions/checkout@v2 + - name: install sccache + if: matrix.os == 'ubuntu-latest' + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.2.15 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + chmod +x $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: cache cargo registry + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: cache sccache + uses: actions/cache@v2 + continue-on-error: false + with: + path: ${{ matrix.sccache-path }} + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: start sccache server + run: sccache --start-server + - name: init + run: make init + - name: build + run: make build + - name: stop sccache server + run: sccache --stop-server || true + test: + name: test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + include: + - os: ubuntu-latest + sccache-path: /home/runner/.cache/sccache + env: + RUST_BACKTRACE: full + RUSTC_WRAPPER: sccache + RUSTV: ${{ matrix.rust }} + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: ${{ matrix.sccache-path }} + # SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out + steps: + - uses: actions/checkout@v2 + - name: install sccache + if: matrix.os == 'ubuntu-latest' + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.2.15 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + chmod +x $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: cache cargo registry + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: cache sccache + uses: actions/cache@v2 + continue-on-error: false + with: + path: ${{ matrix.sccache-path }} + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: start sccache server + run: sccache --start-server + - name: init + run: make init + - name: test + run: make test + - name: stop sccache server + run: sccache --stop-server || true + clippy: + name: clippy (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + include: + - os: ubuntu-latest + sccache-path: /home/runner/.cache/sccache + env: + RUST_BACKTRACE: full + RUSTC_WRAPPER: sccache + RUSTV: ${{ matrix.rust }} + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: ${{ matrix.sccache-path }} + # SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out + steps: + - uses: actions/checkout@v2 + - name: install sccache + if: matrix.os == 'ubuntu-latest' + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.2.15 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + chmod +x $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: cache cargo registry + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: cache sccache + uses: actions/cache@v2 + continue-on-error: false + with: + path: ${{ matrix.sccache-path }} + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: start sccache server + run: sccache --start-server + - name: init + run: make init + - name: clippy + run: make clippy + - name: stop sccache server + run: sccache --stop-server || true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7e4b8d2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +--- +# see: https://www.infinyon.com/blog/2021/04/github-actions-best-practices +name: release +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+* +env: + CARGO_TERM_COLOR: always +jobs: + publish: + name: publish (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + include: + - os: ubuntu-latest + sccache-path: /home/runner/.cache/sccache + env: + RUST_BACKTRACE: full + RUSTC_WRAPPER: sccache + RUSTV: ${{ matrix.rust }} + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: ${{ matrix.sccache-path }} + # SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out + steps: + - name: parse-tag + id: parse_tag + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + return context.payload.ref.replace(/refs\/tags\//, '') + - uses: actions/checkout@v2 + - name: install sccache + if: matrix.os == 'ubuntu-latest' + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.2.15 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + chmod +x $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: cache cargo registry + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: cache sccache + uses: actions/cache@v2 + continue-on-error: false + with: + path: ${{ matrix.sccache-path }} + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: start sccache server + run: sccache --start-server + - name: init + run: make init + - name: release + run: make release + - name: stop sccache server + run: sccache --stop-server || true + - name: strip + run: strip target/release/snapr-node + - name: rename + run: mv target/release/snapr-node target/release/snapr_${{ steps.parse_tag.outputs.result }}_amd64 + - name: publish + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + target/release/snapr_${{ steps.parse_tag.outputs.result }}_amd64 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 940b2d5..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Rust - -on: - push: - branches: [ master ] - pull_request: - branches: "**" - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: build-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Init - run: make init - - name: Build - run: make build - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Init - run: make init - - name: Test - run: make test - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: clippy-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Init - run: make init - - name: Clippy - run: make clippy