From 0f1fd059fc81cdca42d380781abe6940e30c9280 Mon Sep 17 00:00:00 2001 From: Zion Nimchuk Date: Mon, 2 Mar 2020 18:42:28 -0800 Subject: [PATCH] Properly setup Azure Pipelines using current system Also sets up Azure artifacts (including for PRs) for AppImages --- .travis/build-linux.bash | 8 +++- .travis/deploy-linux.bash | 30 ++++++++++----- .travis/travis.env | 4 ++ azure-pipelines.yml | 79 +++++++++++++++++++-------------------- 4 files changed, 70 insertions(+), 51 deletions(-) diff --git a/.travis/build-linux.bash b/.travis/build-linux.bash index 19669fe2b5..da6aa5c0d4 100644 --- a/.travis/build-linux.bash +++ b/.travis/build-linux.bash @@ -31,5 +31,9 @@ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_LLVM_SUBMODULE=OFF -DUSE_COTIRE=OFF ninja; build_status=$?; cd .. -# If it compiled succesfully let's deploy -if [ $build_status -eq 0 ] && [ -n "$GITHUB_TOKEN" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then /bin/bash -ex .travis/deploy-linux.bash ; fi + +# If it compiled succesfully let's deploy depending on the build pipeline (Travis, Azure Pipelines) +# BUILD_REASON is an Azure Pipeline variable, and we want to deploy when using Azure Pipelines +if [[ $build_status -eq 0 && ( -n "$BUILD_REASON" || ( "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = false ) ) ]]; then + /bin/bash -ex .travis/deploy-linux.bash +fi diff --git a/.travis/deploy-linux.bash b/.travis/deploy-linux.bash index cf280777be..13575ac15d 100644 --- a/.travis/deploy-linux.bash +++ b/.travis/deploy-linux.bash @@ -36,18 +36,30 @@ if [ "$DEPLOY_APPIMAGE" = "true" ]; then COMM_COUNT="$(git rev-list --count HEAD)" curl -sLO https://github.com/hcorion/uploadtool/raw/master/upload.sh - mv ./RPCS3*.AppImage rpcs3-v${COMM_TAG}-${COMM_COUNT}-${TRAVIS_COMMIT:0:8}_linux64.AppImage + if [[ -n "$BUILD_SOURCEVERSION" ]]; then + COMMIT_HASH=$BUILD_SOURCEVERSION + elif [[ -n "$TRAVIS_COMMIT" ]]; then + COMMIT_HASH=$TRAVIS_COMMIT + fi + + mv ./RPCS3*.AppImage rpcs3-v${COMM_TAG}-${COMM_COUNT}-${COMMIT_HASH:0:8}_linux64.AppImage + + # If we're building using Azure Pipelines, let's copy over the AppImage artifact + if [[ -n "$BUILD_ARTIFACTSTAGINGDIRECTORY" ]]; then + cp ./rpcs3*.AppImage ~/artifacts + fi FILESIZE=($(stat -c %s ./rpcs3*.AppImage)) SHA256SUM=($(sha256sum ./rpcs3*.AppImage)) - - unset TRAVIS_REPO_SLUG - REPO_SLUG=RPCS3/rpcs3-binaries-linux \ - UPLOADTOOL_BODY="$SHA256SUM;${FILESIZE}B"\ - RELEASE_NAME=build-${TRAVIS_COMMIT}\ - RELEASE_TITLE=${COMM_TAG}-${COMM_COUNT}\ - REPO_COMMIT=d812f1254a1157c80fd402f94446310560f54e5f\ - bash upload.sh rpcs3*.AppImage + if [ -n "$GITHUB_TOKEN" ]; then + unset TRAVIS_REPO_SLUG + REPO_SLUG=RPCS3/rpcs3-binaries-linux \ + UPLOADTOOL_BODY="$SHA256SUM;${FILESIZE}B"\ + RELEASE_NAME=build-${TRAVIS_COMMIT}\ + RELEASE_TITLE=${COMM_TAG}-${COMM_COUNT}\ + REPO_COMMIT=d812f1254a1157c80fd402f94446310560f54e5f\ + bash upload.sh rpcs3*.AppImage + fi fi if [ "$DEPLOY_PPA" = "true" ]; then export DEBFULLNAME="RPCS3 Build Bot" diff --git a/.travis/travis.env b/.travis/travis.env index 09f875c772..6494524af0 100644 --- a/.travis/travis.env +++ b/.travis/travis.env @@ -2,6 +2,10 @@ TRAVIS_PULL_REQUEST TRAVIS_BRANCH TRAVIS_COMMIT +# Variables set by Azure Pipelines +BUILD_REASON +BUILD_SOURCEVERSION +BUILD_ARTIFACTSTAGINGDIRECTORY # Variables for Travis build matrix COMPILER DEPLOY_APPIMAGE diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7a3229be5f..d80b3f5296 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,41 +1,40 @@ -variables: - COMPILER: clang - CCACHE_DIR: $(Pipeline.Workspace)/ccache - trigger: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- bash: | - sudo apt-get install ccache -y - echo "##vso[task.prependpath]/usr/lib/ccache" - displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc - -- task: CacheBeta@0 - inputs: - key: ccache | $(Agent.OS) - path: $(CCACHE_DIR) - displayName: ccache - -- bash: | - docker pull rpcs3/rpcs3-travis-trusty:1.1 - docker run \ - -v $(pwd):/rpcs3 \ - -v $CCACHE_DIR:/root/.ccache \ - rpcs3/rpcs3-travis-trusty:1.1 \ - /bin/bash -ex /rpcs3/.travis/build-linux.bash - displayName: Fetch and build with Docker - -- task: CopyFiles@2 - inputs: - sourceFolder: '$(Build.SourcesDirectory)' - contents: 'build/bin/rpcs3' - TargetFolder: '$(Pipeline.Workspace)/artifacts' - -- task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: '$(Pipeline.Workspace)/artifacts' - artifactName: drop + branches: + include: + - master + tags: + exclude: + - '*' +jobs: +- job: Linux_Build + strategy: + matrix: + Clang: + COMPILER: clang + GCC: + COMPILER: gcc + DEPLOY_APPIMAGE: true + variables: + COMPILER: clang + CCACHE_DIR: $(Pipeline.Workspace)/ccache + pool: + vmImage: 'ubuntu-latest' + steps: + - task: Cache@0 + inputs: + key: ccache | $(Agent.OS) | $(COMPILER) + path: $(CCACHE_DIR) + displayName: Ccache + + - bash: | + docker pull --quiet rpcs3/rpcs3-travis-xenial:1.2 + docker run \ + -v $(pwd):/rpcs3 \ + --env-file .travis/travis.env \ + -v $CCACHE_DIR:/root/.ccache \ + -v $BUILD_ARTIFACTSTAGINGDIRECTORY:/root/artifacts \ + rpcs3/rpcs3-travis-xenial:1.2 \ + /bin/bash -ex /rpcs3/.travis/build-linux.bash + displayName: Docker setup and build + + - publish: $(Build.ArtifactStagingDirectory)