From 4131e828c20d4b2713996bf477e466fff592a368 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 28 Jul 2020 09:39:23 -0700 Subject: [PATCH] switch to github actions --- .github/workflows/ci.yml | 82 +++++++++++++++++++++++ .github/workflows/release.yml | 119 +++++++++++++++++++++++++++++++++ .travis.yml | 122 ---------------------------------- appveyor.yml | 75 --------------------- ci/before_deploy.ps1 | 23 ------- ci/before_deploy.sh | 33 --------- ci/install.sh | 50 -------------- ci/script.sh | 26 -------- src/git.rs | 2 - 9 files changed, 201 insertions(+), 331 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 ci/before_deploy.ps1 delete mode 100644 ci/before_deploy.sh delete mode 100644 ci/install.sh delete mode 100644 ci/script.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a9f6c32 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +on: + push: + branches-ignore: + - ci + pull_request: + branches: + - master + +name: Continuous Integration + +jobs: + check: + name: Check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + + fmt: + name: Rustfmt + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c11a95f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,119 @@ +on: + push: + branches: + - ci + tags: + - 'v*' + +name: Create Release + +jobs: + test: + name: Test Suite + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + + release: + name: Create Release + needs: test + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + + build: + name: Build Binaries + needs: release + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: build + args: --release + + - name: Set Asset Names + id: vars + run: | + triple=$(rustup show active-toolchain | awk '{print $1}') + echo "::set-output name=windows_asset::git-together-${GITHUB_REF#refs/*/}-${triple}.zip" + echo "::set-output name=non_windows_asset::git-together-${GITHUB_REF#refs/*/}-${triple}.tar.gz" + shell: bash + + - name: Create Windows Asset + if: matrix.os == 'windows-latest' + run: | + $SRC_DIR = $pwd.Path + $STAGE = [System.Guid]::NewGuid().ToString() + + Set-Location $env:TEMP + New-Item -Type Directory -Name $STAGE + Set-Location $STAGE + + $ZIP = "$SRC_DIR\${{ steps.vars.outputs.windows_asset }}" + + Copy-Item "$SRC_DIR\target\release\git-together.exe" '.\' + + 7z a "$ZIP" * + + Remove-Item *.* -Force + Set-Location .. + Remove-Item $STAGE + Set-Location $SRC_DIR + + - name: Create Non-Windows Asset + if: matrix.os != 'windows-latest' + run: | + tar -zvc target/release/git-together > ${{ steps.vars.outputs.non_windows_asset }} + + - name: Upload Windows Release Asset + if: matrix.os == 'windows-latest' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ./${{ steps.vars.outputs.windows_asset }} + asset_name: ${{ steps.vars.outputs.windows_asset }} + asset_content_type: application/zip + + - name: Upload Non-Windows Release Asset + if: matrix.os != 'windows-latest' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ./${{ steps.vars.outputs.non_windows_asset }} + asset_name: ${{ steps.vars.outputs.non_windows_asset }} + asset_content_type: application/gzip diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6baf94d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,122 +0,0 @@ -# Based on the "trust" template v0.1.2 -# https://github.com/japaric/trust/tree/v0.1.2 - -dist: trusty -language: rust -services: docker -sudo: required - -env: - global: - - CRATE_NAME=git-together - -matrix: - include: - # Android - # - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 - # - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 - # - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 - # - env: TARGET=i686-linux-android DISABLE_TESTS=1 - # - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 - - # iOS - # - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1 - # os: osx - # - env: TARGET=armv7-apple-ios DISABLE_TESTS=1 - # os: osx - # - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1 - # os: osx - # - env: TARGET=i386-apple-ios DISABLE_TESTS=1 - # os: osx - # - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1 - # os: osx - - # Linux - # - env: TARGET=aarch64-unknown-linux-gnu - # - env: TARGET=arm-unknown-linux-gnueabi - # - env: TARGET=armv7-unknown-linux-gnueabihf - # - env: TARGET=i686-unknown-linux-gnu - # - env: TARGET=i686-unknown-linux-musl - # - env: TARGET=mips-unknown-linux-gnu - # - env: TARGET=mips64-unknown-linux-gnuabi64 - # - env: TARGET=mips64el-unknown-linux-gnuabi64 - # - env: TARGET=mipsel-unknown-linux-gnu - # - env: TARGET=powerpc-unknown-linux-gnu - # - env: TARGET=powerpc64-unknown-linux-gnu - # - env: TARGET=powerpc64le-unknown-linux-gnu - # - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 - # - env: TARGET=x86_64-unknown-linux-gnu - # - env: TARGET=x86_64-unknown-linux-musl - - # OSX - # - env: TARGET=i686-apple-darwin - # os: osx - # - env: TARGET=x86_64-apple-darwin - # os: osx - - # *BSD - # - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 - # - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 - # - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 - - # Windows - # - env: TARGET=x86_64-pc-windows-gnu - - # Bare metal - # These targets don't support std and as such are likely not suitable for - # most crates. - # - env: TARGET=thumbv6m-none-eabi - # - env: TARGET=thumbv7em-none-eabi - # - env: TARGET=thumbv7em-none-eabihf - # - env: TARGET=thumbv7m-none-eabi - - # Testing other channels - - env: TARGET=x86_64-apple-darwin - os: osx - rust: nightly - - env: TARGET=x86_64-unknown-linux-gnu - os: linux - rust: nightly - -before_install: - - set -e - - rustup self update - -install: - - sh ci/install.sh - - source ~/.cargo/env || true - -script: - - bash ci/script.sh - -after_script: set +e - -before_deploy: - - sh ci/before_deploy.sh - -deploy: - api_key: - secure: NYjh1w9WlTc7QKGAWZqrOeUXGyojRGR8CCWlbqMibuoN73O/E183jhu8dND2cBLl3x1vBxnMfd1i9h/9jTcyP7JJjEWRBlOYRWRKmmiU6SuvX2Xphsvmoe5PbT331ttiynaiWte00lqItLwCWHvjzw9hhZoQDQDdlRhixMG6bmOYdeZEWWHvFkrqhLUlxHIX/KJeV+gEEi86uSvi+nFIDfokijdS6N4EjmIsCwFBMvhU+LyvheY8oRBy+MtSJuUqtfzKMMYJO65SJiuXzR4ipYA0v9o0h5WrOOoMtCjF5dhZMGUhRjfZ7OQ69uHfACfq/olp6nq5fIQlJRgUkBwvFqh8ekBAslCzKfQgg7OzMReW2q0gVBQMvlx/ZnquArCTPwsQQIl3AhknygvsjfQ6LMzEZGRpq1mV809BVqtYUU+XbRMnQfEBiyGkMQEUpF9VOUIPO/JpwyhSyVTkKIKUmSu6dKmaG+Uvbc+LmmfXm6U2QcjV9HOTnN9hxOAqbZOg5oT/NrbjXeiRHQzaQXQ8C8DbB3bV5meHyaEnJX8nBao8P6lij2JHckqVibB3P53dJdeKqOM7V6+bSmbPjEgf9a0MI/wqeFgk+11lnuBC7QjcIEnTV306wElrcb0TrEHu+gE7Zfvnx+JAiXehSo1qAQLKJmHcU7PNwoUwvnggRO0= - file_glob: true - file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* - on: - # condition: $TRAVIS_RUST_VERSION = nightly - tags: true - provider: releases - skip_cleanup: true - -cache: cargo -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo - -branches: - only: - # release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - - ci - -notifications: - email: - on_success: never diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 2874f7c..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Based on the "trust" template v0.1.2 -# https://github.com/japaric/trust/tree/v0.1.2 - -environment: - global: - RUST_VERSION: nightly - CRATE_NAME: git-together - - matrix: - # MinGW - # - TARGET: i686-pc-windows-gnu - # - TARGET: x86_64-pc-windows-gnu - - # MSVC - - TARGET: i686-pc-windows-msvc - - TARGET: x86_64-pc-windows-msvc - - # Testing other channels - # - TARGET: x86_64-pc-windows-gnu - # RUST_VERSION: nightly - # - TARGET: x86_64-pc-windows-msvc - # RUST_VERSION: nightly - -install: - - ps: >- - If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw64\bin' - } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw32\bin' - } - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - rustc -Vv - - cargo -V - -test_script: - # we don't run the "test phase" when doing deploys - - if [%APPVEYOR_REPO_TAG%]==[false] ( - cargo build --target %TARGET% && - cargo build --target %TARGET% --release && - cargo test --target %TARGET% && - cargo test --target %TARGET% --release - ) - -before_deploy: - - cargo rustc --target %TARGET% --release --bin git-together -- -C lto - - ps: ci\before_deploy.ps1 - -deploy: - artifact: /.*\.zip/ - auth_token: - secure: T9yKTsNbrLznooZdBs2Nlj0thPKXz/G3RzDac8HPyzQRNUFh1hx+jRU8kOkSzKEG - description: '' - on: - RUST_VERSION: nightly - appveyor_repo_tag: true - provider: GitHub - -cache: - - C:\Users\appveyor\.cargo\registry - - target - -branches: - only: - # Release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - -notifications: - - provider: Email - on_build_success: false - -# Building is done in the test phase, so we disable Appveyor's build phase. -build: false diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 deleted file mode 100644 index 4912a1d..0000000 --- a/ci/before_deploy.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -# This script takes care of packaging the build artifacts that will go in the -# release zipfile - -$SRC_DIR = $PWD.Path -$STAGE = [System.Guid]::NewGuid().ToString() - -Set-Location $ENV:Temp -New-Item -Type Directory -Name $STAGE -Set-Location $STAGE - -$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" - -# TODO Update this to package the right artifacts -Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\git-together.exe" '.\' - -7z a "$ZIP" * - -Push-AppveyorArtifact "$ZIP" - -Remove-Item *.* -Force -Set-Location .. -Remove-Item $STAGE -Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh deleted file mode 100644 index a90ef31..0000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -1,33 +0,0 @@ -# This script takes care of building your crate and packaging it for release - -set -ex - -main() { - local src=$(pwd) \ - stage= - - case $TRAVIS_OS_NAME in - linux) - stage=$(mktemp -d) - ;; - osx) - stage=$(mktemp -d -t tmp) - ;; - esac - - test -f Cargo.lock || cargo generate-lockfile - - # TODO Update this to build the artifacts that matter to you - cross rustc --bin git-together --target $TARGET --release -- -C lto - - # TODO Update this to package the right artifacts - cp target/$TARGET/release/git-together $stage/ - - cd $stage - tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * - cd $src - - rm -rf $stage -} - -main diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index f3379d9..0000000 --- a/ci/install.sh +++ /dev/null @@ -1,50 +0,0 @@ -set -ex - -main() { - local target= - if [ $TRAVIS_OS_NAME = linux ]; then - target=x86_64-unknown-linux-musl - sort=sort - else - target=x86_64-apple-darwin - sort=gsort # for `sort --sort-version`, from brew's coreutils. - fi - - # Builds for iOS are done on OSX, but require the specific target to be - # installed. - case $TARGET in - aarch64-apple-ios) - rustup target install aarch64-apple-ios - ;; - armv7-apple-ios) - rustup target install armv7-apple-ios - ;; - armv7s-apple-ios) - rustup target install armv7s-apple-ios - ;; - i386-apple-ios) - rustup target install i386-apple-ios - ;; - x86_64-apple-ios) - rustup target install x86_64-apple-ios - ;; - esac - - # This fetches latest stable release - local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ - | cut -d/ -f3 \ - | grep -E '^v[0.1.0-9.]+$' \ - | $sort --version-sort \ - | tail -n1) - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- \ - --force \ - --git japaric/cross \ - --tag $tag \ - --target $target - - git clone https://github.com/sstephenson/bats.git /tmp/bats - /tmp/bats/install.sh $HOME -} - -main diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index 95b71ae..0000000 --- a/ci/script.sh +++ /dev/null @@ -1,26 +0,0 @@ -# This script takes care of testing your crate - -set -ex - -# TODO This is the "test phase", tweak it as you see fit -main() { - cross build --target $TARGET - cross build --target $TARGET --release - - if [ ! -z $DISABLE_TESTS ]; then - return - fi - - cross test --target $TARGET - cross test --target $TARGET --release - - # cross run --target $TARGET - # cross run --target $TARGET --release - - ~/bin/bats --tap bats -} - -# we don't run the "test phase" when doing deploys -if [ -z $TRAVIS_TAG ]; then - main -fi diff --git a/src/git.rs b/src/git.rs index 904439b..ac2ae97 100644 --- a/src/git.rs +++ b/src/git.rs @@ -1,8 +1,6 @@ use std::collections::HashMap; use std::env; -use git2; - use crate::config; use crate::errors::*; use crate::ConfigScope;