Skip to content

cloudbees

cloudbees #617

Workflow file for this run

---
name: Rust
on:
push:
branches: [main]
pull_request:
paths: # Make sure to keep sync'd https://github.com/pyrsia/pyrsia/blob/main/.github/workflows/rust-skipped.yml#L8
- .github/workflows/rust.yml
- '**/*.rs'
- '**/Cargo.toml'
- Cargo.lock
- 'installers/**'
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
# OS/X Build Job
build-osx:
permissions:
contents: 'read'
id-token: 'write'
runs-on: macos-12
env:
RUSTC_WRAPPER: /Users/runner/.cargo/bin/sccache
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: /Users/runner/Library/Caches/Mozilla.sccache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-macos.sh
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: set-cargo-version
# Need to add build number to version number
- id: add-fqbvn-and-export
name: Add Build Number to Version Number and Export to Output
# if: github.repository_owner == 'pyrsia' && github.event_name == 'push' && github.event.pull_request.merged == true
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
echo "TAG_NAME=${{ env.PKG_VERSION }}+${{ github.run_number }}" >> $GITHUB_OUTPUT
shell: /bin/zsh -e {0}
- name: Build Release and Test Binaries
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Creates installer archive of pyrsia and pyrsia_node
- id: generate-homebrew-archives
name: Create Pyrsia Homebrew archives
run: |
tar -C target/release -czf pyrsia-${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }}.tar.gz pyrsia pyrsia_node
shell: /bin/zsh -e {0}
- id: build-osx-google-auth
name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
- id: build-osx-setup-cloud-sdk
name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
- id: build-osx-install-crcmod-gsutil-version-info
name: 'Install crcmod and gsutil version info'
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
pip3 install -U crcmod
gsutil version -l
gcloud info
shell: /bin/zsh -e {0}
# Publish nightly version of installer archive to cloud bucket
- id: build-osx-publish-nightly-gcs-repo
name: Publish Build to NIGHTLY GCS repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/homebrew-installer-upload.sh ${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }} latest x86_64
shell: /bin/zsh -e {0}
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Publish stable version of installer archive to cloud bucket
- id: build-osx-publish-stable-gcs-repo
name: Publish Release to STABLE GCS repo
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/homebrew-installer-upload.sh ${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }} stable x86_64
shell: /bin/zsh -e {0}
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Windows Build Job
build-windows:
runs-on: windows-2022
env:
RUSTC_WRAPPER: C:\Users\runneradmin\.cargo\bin\sccache.exe
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: C:/Users/runneradmin/AppData/Local/Mozilla/sccache/cache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install and start sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-windows.bat
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: set-cargo-version
# Need to add build number to version number
- name: Add Build to Version Number
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
- name: Build Release and Test Binaries
shell: bash
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Create installers
- name: Create MSIs
shell: bash
# todo: uncomment: if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
env:
WIX_PATH_CANDLE: "C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe"
WIX_PATH_LIGHT: "C:/Program Files (x86)/WiX Toolset v3.11/bin/light.exe"
run: |
cd installers/windows
"$WIX_PATH_CANDLE" -ext WixUIExtension -ext WixUtilExtension installer.wxs
"$WIX_PATH_LIGHT" -ext WixUIExtension -ext WixUtilExtension installer.wixobj -out pyrsia.msi
"$WIX_PATH_CANDLE" -ext WixUIExtension -ext WixUtilExtension installerps1.wxs
"$WIX_PATH_LIGHT" -ext WixUIExtension -ext WixUtilExtension installerps1.wixobj -out pyrsia_service.msi
cd ../..
# for now, upload installers
- name: Upload Installer
uses: actions/upload-artifact@v3
with:
name: windows-installer
path: ${{ github.workspace }}/installers/windows/pyrsia.msi
- name: Upload Installer_with_Service
uses: actions/upload-artifact@v3
with:
name: windows-installer-with-service
path: ${{ github.workspace }}/installers/windows/pyrsia_service.msi
build-push-linux:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-20.04
env:
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: /home/runner/.cache/sccache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install and start sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-linux.sh
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: cargo-deb set-cargo-version
# Need to add build number to version number
- name: Add Build to Version Number
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
# Run cargo build in parallel using sscache to avoid OS locking errors
- name: Build Release and Test Binaries
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Create Pyrsia .deb file
- name: Package Pyrsia as deb file
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
cargo deb --no-build -v
# Login to GCS
- name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
# Add gsutils
- name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
# Add the prysia .deb file to the NIGHTLY apt repo which resides on GCS
- name: Publish Build to NIGHTLY GCS repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/aptly.sh target/debian/pyrsia_${{ env.PKG_VERSION }}+${{ github.run_number }}_amd64.deb nightly
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Add the prysia .deb file to the STABLE apt repo which resides on GCS
- name: Publish Release to STABLE GCS repo
# Only add to STABLE on publishing of a release
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/aptly.sh target/debian/pyrsia_${{ env.PKG_VERSION }}+${{ github.run_number }}_amd64.deb stable
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
coverage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: pyrsia/rust-toolchain@v2
with:
packages: cargo-tarpaulin
- name: Run cargo-tarpaulin
run: |
cargo tarpaulin --workspace --lib --bins --tests --benches --out Lcov --output-dir ./coverage
- name: Upload to coveralls.io
id: coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display coveralls.io link
run: |
echo '${{ steps.coveralls.outputs.coveralls-api-result }}' | jq -r ".url" | xargs echo Reults
# Docker build that uses the published .deb file from the Linux build
docker:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-20.04
needs: [build-push-linux]
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
steps:
- uses: actions/checkout@v3
- uses: pyrsia/rust-toolchain@v2 # Setup toolchain to pull version info from Cargo.toml
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker Image for Pyrsia Node
uses: docker/build-push-action@v4
with:
context: .
push: true
file: installers/docker/AptGet.Dockerfile
tags: pyrsiaoss/pyrsia-node:${{ env.PKG_VERSION }}-${{ github.run_number }}
build-args: |
GIT_REPO=${{ github.repository }}
GIT_COMMIT=${{ github.sha }}
GIT_BRANCH=${{ github.ref_name }}
PYRSIA_VERSION=${{ env.PKG_VERSION }}+${{ github.run_number }}
# Update the helm chart values with the image tag
- name: Add Build to Version Number in Chart and Values files
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
sudo go install github.com/mikefarah/yq/v4@latest
yq e '.image.tag |= "${{ env.PKG_VERSION }}-${{ github.run_number }}"' -i installers/helm/pyrsia-node/values.yaml
yq e '.version |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-node/Chart.yaml
yq e '.appVersion |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-node/Chart.yaml
# Login to GCS
- name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
# Add gsutils
- name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
# Add the updated helm chart to the helm NIGHTLY repo
- name: Add the updated helm chart to the helm NIGHTLY repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/chartmuseum.sh nightly
# Add the updated helm chart to the helm STABLE repo
- name: Add the updated helm chart to the helm STABLE repo
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/chartmuseum.sh stable