From 99abbb87a195e98c7a3fafbdc268dc0d5a7ad0fd Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 19 Jul 2019 10:35:31 +0200 Subject: [PATCH] Set up CI with Azure Pipelines (#750) * Set up CI with Azure Pipelines [skip ci] * Remove other CI + remove newline in anchor link tpl * Some more Windows specific changes --- .travis.yml | 60 -------- appveyor.yml | 57 -------- azure-pipelines.yml | 133 ++++++++++++++++++ ci/before_deploy.ps1 | 22 --- ci/before_deploy.sh | 31 ---- ci/install.sh | 31 ---- ci/script.sh | 17 --- components/rendering/tests/markdown.rs | 14 +- .../templates/src/builtins/anchor-link.html | 2 +- .../templates/src/global_fns/load_data.rs | 18 ++- 10 files changed, 156 insertions(+), 229 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.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/.travis.yml b/.travis.yml deleted file mode 100644 index 0f9298f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -dist: trusty -language: rust -services: docker - -env: - global: - - CRATE_NAME=zola - -matrix: - include: - # Linux - - env: TARGET=x86_64-unknown-linux-gnu - # OSX - - env: TARGET=x86_64-apple-darwin - os: osx - - # The earliest stable Rust version that works - - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.34.0 - - -before_install: set -e - -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: "nksXOY7p8vAWDpItN9Tyx+0CmOPMj/iAgH+iT512URpgJG/i+ziUWDEYpQO4PfZMJUDUa1tnSZ31O4MIe2Sgfj6DHR1zK+LKeLaZxuxxJUSMXSAkbIXcjFlOPKQBPnMZVVcDaHMxz18jiRpElDR2k0PIEtspW2rDsrr+7mzmQn7pan60k77tU3RG3K7fYgMmNjVv64XqMBSCS3fpqiroIz7rVL1HZ3sCoTNnxDM8nXo/8gTjlVowTvUTsVyHRgtDRJdlPuI0yf4oJmvQPX74P2OkQmOVpGxeJ/gSTJ1xWxYfMgyvNaiO9NKF+fUfxvHR/V58CfBHPdJkcnThV5KIPjE5mHZfSTFf5cG6gJtnVhvhQV7vBhIRI/iCt55SPCXse1HWzTY1GxE5oXw2VzUt/kzD2pFf8rtf64JURgGolenYv3aw+ps1MGUwUjl8CF31XBSiASVwpif7kd9P3bafg6pGUytfjgpV/wJJc8OpO8IGwTSNe4r0wtcFb92stxta4NKC3L4F0w/juaK+0+Mjt4SCyh6rRzpHQu9TJKniskp7/URp5KhMFAo66sFpgSYVa23OTkYmjtB8IqlJzmpuDSs/WSAVA8InSgHDaQeBd0UEbNaWU1+avtAGBtb8+rZnbw7ikPF0j2pHImD5ZjHp7+jt/hpcwqrOkBuB5CSeBKs=" - file_glob: true - file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* - on: - condition: $TRAVIS_RUST_VERSION = stable - 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 - - next - -notifications: - email: false diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bfa5bb6..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,57 +0,0 @@ -# Based on the "trust" template v0.1.1 -# https://github.com/japaric/trust/tree/v0.1.1 - -os: Visual Studio 2017 - -environment: - global: - RUST_VERSION: stable - CRATE_NAME: zola - - matrix: - - target: x86_64-pc-windows-msvc - RUST_VERSION: 1.34.0 - - target: x86_64-pc-windows-msvc - RUST_VERSION: stable - -install: - - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 - - 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 test --all --target %TARGET% - ) - -before_deploy: - - cargo rustc --target %TARGET% --release --bin zola -- -C lto - - ps: ci\before_deploy.ps1 - -deploy: - artifact: /.*\.zip/ - auth_token: - secure: i64eFOHoySQryE3M9pr2JGRukAK3LGltOsUxeFHwilS+3O6/6828A4NUmI0FW4zN - description: '' - on: - RUST_VERSION: stable - appveyor_repo_tag: true - provider: GitHub - -cache: - - C:\Users\appveyor\.cargo\registry - - target - -branches: - only: - # Release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - - next - -# disable automatic builds -build: false diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..fcbe8cb --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,133 @@ +trigger: + branches: + include: ['*'] + tags: + include: ['*'] + +stages: + - stage: Tests + jobs: + - job: + strategy: + matrix: + windows-stable: + imageName: 'vs2017-win2016' + rustup_toolchain: stable + mac-stable: + imageName: 'macos-10.14' + rustup_toolchain: stable + linux-stable: + imageName: 'ubuntu-16.04' + rustup_toolchain: stable + linux-1.34: + imageName: 'ubuntu-16.04' + rustup_toolchain: 1.34.0 + pool: + vmImage: $(imageName) + steps: + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Install rust + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + displayName: Windows install rust + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + - script: cargo build --all + displayName: Cargo build + - script: cargo test --all + displayName: Cargo test + + + - stage: Release + dependsOn: Tests + condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') + jobs: + - job: + strategy: + matrix: + windows-stable: + imageName: 'vs2017-win2016' + rustup_toolchain: stable + target: 'x86_64-pc-windows-msvc' + mac-stable: + imageName: 'macos-10.14' + rustup_toolchain: stable + target: 'x86_64-apple-darwin' + linux-stable: + imageName: 'ubuntu-16.04' + rustup_toolchain: stable + target: 'x86_64-unknown-linux-gnu' + pool: + vmImage: $(imageName) + steps: + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Install rust + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + displayName: Windows install rust + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + + - script: | + rustup target add $TARGET + cargo build --release --target $TARGET + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + displayName: Build + - script: | + rustup target add %TARGET% + cargo build --release --target %TARGET% + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + displayName: Build on Windows + + - task: CopyFiles@2 + displayName: Copy assets + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + inputs: + sourceFolder: '$(Build.SourcesDirectory)/target/$(TARGET)/release' + contents: zola + targetFolder: '$(Build.BinariesDirectory)/' + - task: CopyFiles@2 + displayName: Copy assets on Windows + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + inputs: + sourceFolder: '$(Build.SourcesDirectory)/target/$(TARGET)/release' + contents: zola.exe + targetFolder: '$(Build.BinariesDirectory)/' + + - task: ArchiveFiles@2 + displayName: Gather assets + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)/zola' + archiveType: 'tar' + tarCompression: 'gz' + archiveFile: '$(Build.ArtifactStagingDirectory)/zola-$(Build.SourceBranchName)-$(TARGET).tar.gz' + - task: ArchiveFiles@2 + displayName: Gather assets + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)/zola.exe' + archiveType: 'tar' + tarCompression: 'gz' + archiveFile: '$(Build.ArtifactStagingDirectory)/zola-$(Build.SourceBranchName)-$(TARGET).tar.gz' + + - task: GithubRelease@0 + inputs: + gitHubConnection: 'zola' + repositoryName: 'keats/azure-pipelines-test' + action: 'edit' + target: '$(build.sourceVersion)' + tagSource: 'manual' + tag: '$(Build.SourceBranchName)' + assets: '$(Build.ArtifactStagingDirectory)/zola-$(Build.SourceBranchName)-$(TARGET).tar.gz' + title: '$(Build.SourceBranchName)' + assetUploadMode: 'replace' + addChangeLog: true diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 deleted file mode 100644 index 08bd1d2..0000000 --- a/ci/before_deploy.ps1 +++ /dev/null @@ -1,22 +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" - -Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\zola.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 e2f9fe0..0000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -1,31 +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 - - cross rustc --bin zola --target $TARGET --release -- -C lto - - cp target/$TARGET/release/zola $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 76bb734..0000000 --- a/ci/install.sh +++ /dev/null @@ -1,31 +0,0 @@ -set -ex - -main() { - curl https://sh.rustup.rs -sSf | \ - sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION - - local target= - if [ $TRAVIS_OS_NAME = linux ]; then - target=x86_64-unknown-linux-gnu - sort=sort - else - target=x86_64-apple-darwin - sort=gsort # for `sort --sort-version`, from brew's coreutils. - fi - - # 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-9.]+$' \ - | $sort --version-sort \ - | tail -n1) - echo cross version: $tag - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- \ - --force \ - --git japaric/cross \ - --tag $tag \ - --target $target -} - -main diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index aaf17fe..0000000 --- a/ci/script.sh +++ /dev/null @@ -1,17 +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() { - if [ ! -z $DISABLE_TESTS ]; then - return - fi - - cross test --all --target $TARGET -} - -# we don't run the "test phase" when doing deploys -if [ -z $TRAVIS_TAG ]; then - main -fi diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index 42c4768..37ec910 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -409,7 +409,7 @@ fn can_insert_anchor_left() { let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, - "

🔗\nHello

\n" + "

🔗Hello

\n" ); } @@ -421,7 +421,7 @@ fn can_insert_anchor_right() { let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, - "

Hello🔗\n

\n" + "

Hello🔗

\n" ); } @@ -433,8 +433,8 @@ fn can_insert_anchor_for_multi_header() { let res = render_content("# Hello\n# World", &context).unwrap(); assert_eq!( res.body, - "

Hello🔗\n

\n\ -

World🔗\n

\n" + "

Hello🔗

\n\ +

World🔗

\n" ); } @@ -447,7 +447,7 @@ fn can_insert_anchor_with_exclamation_mark() { let res = render_content("# Hello!", &context).unwrap(); assert_eq!( res.body, - "

🔗\nHello!

\n" + "

🔗Hello!

\n" ); } @@ -460,7 +460,7 @@ fn can_insert_anchor_with_link() { let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap(); assert_eq!( res.body, - "

🔗\nRust

\n" + "

🔗Rust

\n" ); } @@ -472,7 +472,7 @@ fn can_insert_anchor_with_other_special_chars() { let res = render_content("# Hello*_()", &context).unwrap(); assert_eq!( res.body, - "

🔗\nHello*_()

\n" + "

🔗Hello*_()

\n" ); } diff --git a/components/templates/src/builtins/anchor-link.html b/components/templates/src/builtins/anchor-link.html index cea5e50..4f6256d 100644 --- a/components/templates/src/builtins/anchor-link.html +++ b/components/templates/src/builtins/anchor-link.html @@ -1 +1 @@ -🔗 +🔗 \ No newline at end of file diff --git a/components/templates/src/global_fns/load_data.rs b/components/templates/src/global_fns/load_data.rs index f932eca..c45c949 100644 --- a/components/templates/src/global_fns/load_data.rs +++ b/components/templates/src/global_fns/load_data.rs @@ -445,7 +445,11 @@ mod tests { args.insert("path".to_string(), to_value("test.css").unwrap()); let result = static_fn.call(&args.clone()).unwrap(); - assert_eq!(result, ".hello {}\n",); + if cfg!(windows) { + assert_eq!(result, ".hello {}\r\n",); + } else { + assert_eq!(result, ".hello {}\n",); + }; } #[test] @@ -456,7 +460,11 @@ mod tests { args.insert("format".to_string(), to_value("plain").unwrap()); let result = static_fn.call(&args.clone()).unwrap(); - assert_eq!(result, "Number,Title\n1,Gutenberg\n2,Printing",); + if cfg!(windows) { + assert_eq!(result, "Number,Title\r\n1,Gutenberg\r\n2,Printing",); + } else { + assert_eq!(result, "Number,Title\n1,Gutenberg\n2,Printing",); + }; } #[test] @@ -467,7 +475,11 @@ mod tests { args.insert("format".to_string(), to_value("plain").unwrap()); let result = static_fn.call(&args.clone()).unwrap(); - assert_eq!(result, ".hello {}\n",); + if cfg!(windows) { + assert_eq!(result, ".hello {}\r\n",); + } else { + assert_eq!(result, ".hello {}\n",); + }; } #[test]