Skip to content

Fix/tsp 1130

Fix/tsp 1130 #91

Workflow file for this run

name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
push:
tags:
- '*'
jobs:
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: taiki-e/install-action@just
- name: Check Style
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
just check-fmt
lint:
name: Lint
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: taiki-e/install-action@just
- name: Lint
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
just lint
sbom:
name: Generate CycloneDX
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@cargo-cyclonedx
- name: Generate SBOMs
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
just sbom
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: software-bom
path: |
**/*.cdx.json
test:
name: Test
strategy:
matrix:
include:
- runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
vscode-platform: linux-x64
- runner: windows-latest
triple: x86_64-pc-windows-msvc
vscode-platform: win32-x64
- runner: macos-latest
triple: aarch64-apple-darwin
vscode-platform: darwin-arm64
runs-on: ${{matrix.runner}}
env:
CARGO_HOME: ".cargo"
LIB_VISA_PATH: "${{github.workflow}}"
TEST_DIR: "test-results"
LLVM_PROFILE_FILE: "../test-results/%p-%m.profraw"
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@cargo-nextest
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Tool versions
run: rustc --version --verbose
- name: Run Tests with Coverage
if: true
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
just test-cov # need to wait for https://github.com/rust-lang/rust/issues/140677 to get coverage
- name: Run Tests without Coverage
if: false
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
#just test-cov # need to wait for https://github.com/rust-lang/rust/issues/140677 to get coverage
just test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure()
with:
report_paths: "${{env.TEST_DIR}}/*.junit.xml"
- name: Upload Results
uses: actions/upload-artifact@v4
if: ${{always()}}
with:
name: unit-test-report-${{matrix.vscode-platform}}
path: |
${{env.TEST_DIR}}
code_coverage: #TODO Re-enable when we can do coverage
name: Code Coverage
runs-on: ubuntu-latest
env:
TEST_DIR: "test-results"
needs: test
if: true
strategy:
matrix:
include:
- runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
vscode-platform: linux-x64
steps:
- name: Download Test Results
uses: actions/download-artifact@v4
with:
name: unit-test-report-${{matrix.vscode-platform}}
path: test-results
- name: Display structure of downloaded files
run: ls -R
- name: Setup .NET Core # Required to execute ReportGenerator
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-quality: 'ga'
- name: ReportGenerator
uses: danielpalme/[email protected]
with:
reports: ${{env.TEST_DIR}}/*.cobertura.xml
targetdir: test-results
reporttypes: Html;MarkdownSummaryGithub
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
continue-on-error: true
if: github.event_name == 'pull_request'
with:
header: Test Coverage
path: test-results/SummaryGithub.md
build:
name: Build
strategy:
matrix:
include:
- runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
vscode-platform: linux-x64
- runner: windows-latest
triple: x86_64-pc-windows-msvc
vscode-platform: win32-x64
- runner: macos-latest
triple: aarch64-apple-darwin
vscode-platform: darwin-arm64
runs-on: ${{matrix.runner}}
env:
RUSTFLAGS: "-L ${{github.workspace}}"
LIB_VISA_PATH: "${{github.workflow}}"
steps:
- uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{matrix.triple}}
- uses: taiki-e/install-action@just
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
git config --global credential.helper store
echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials
just build-release ${{matrix.triple}}
just pre-package ${{matrix.triple}}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{matrix.vscode-platform}}-executable
path: |
bin/*
package:
name: Package
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
#https://github.com/actions/runner/issues/2033#issuecomment-1598547465
#options: --user 1001
needs: build
strategy:
matrix:
include:
- runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
vscode-platform: linux-x64
os: linux
arch: x64
- runner: windows-latest
triple: x86_64-pc-windows-msvc
vscode-platform: win32-x64
os: win32
arch: x64
- runner: macos-latest
triple: aarch64-apple-darwin
vscode-platform: darwin-arm64
os: darwin
arch: arm64
steps:
- name: Update ClamAV
run: freshclam
- name: Tool Versions
run: |
npm --version
clamscan -V
- name: Checkout
uses: actions/checkout@v4
with:
#set-safe-directory: "${{github.workspace}}"
fetch-depth: 0
fetch-tags: true
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
name: ${{matrix.vscode-platform}}-executable
path: bin/
- name: Get Tagged Version
id: lasttag
run: |
git config --global --add safe.directory "$PWD"
COMMIT="${{github.sha}}"
if ${{contains(github.head_ref, 'release')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')"
echo "Extracted version: $V"
V="$(echo "v${V}" | sed 's/\"//g')"
echo "Cleaned up version: $V"
fi
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
echo "RC Version: $V"
fi
CL=${V#v}
CL=${CL%-*}
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
npm version --no-git-tag-version "${V}" || true
- uses: taiki-e/install-action@just
- name: Package
run: |
just package ${{matrix.vscode-platform}} ${{matrix.os}} ${{matrix.arch}} ${{matrix.triple}}
- name: Run ClamAV
run: clamscan -v bin/*
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: package-${{matrix.vscode-platform}}
path: ./*.tgz
publish:
name: Publish
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
needs:
- build
- lint
- style
- test
#- code_coverage
- package
- sbom
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
#https://github.com/actions/runner/issues/2033#issuecomment-1598547465
options: --user 1001
steps:
- name: Tool Versions
run: npm --version
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@tektronix'
- name: Checkout
uses: actions/checkout@v4
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
pattern: package-*
merge-multiple: true
- name: publish package
run: |
for f in *.tgz; do
npm publish "$f"
done
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
pull-requests: read
needs:
- build
- lint
- style
- test
#- code_coverage
- package
- sbom
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get Tagged Version
id: lasttag
run: |
git config --global --add safe.directory "$PWD"
COMMIT="${{github.sha}}"
if ${{contains(github.head_ref, 'release')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')"
echo "Extracted version: $V"
V="$(echo "v${V}" | sed 's/\"//g')"
echo "Cleaned up version: $V"
fi
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
echo "RC Version: $V"
fi
CL=${V#v}
CL=${CL%-*}
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
- run: 'git tag --list ${V}*'
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
pattern: "*-executable"
path: target
merge-multiple: true
- name: Get SBOM
uses: actions/download-artifact@v4
with:
name: software-bom
path: sbom
# - name: Get Changelog for this Tag
# id: changelog
# uses: coditory/changelog-parser@v1
# with:
# version: ${{steps.lasttag.outputs.cl_version}}
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{steps.lasttag.outputs.version}}
artifacts: target/*,sbom/**/*
body: |
## Features Requests / Bugs
If you find issues or have a feature request, please enter a [new issue on GitHub](${{github.server_url}}/${{github.repository}}/issues/new).
## Installation
View the installation instructions in the [README](${{github.server_url}}/${{github.repository}}/blob/main/README.md)
## Changelog
TODO <!--$\{{steps.changelog.outputs.description}}-->
prerelease: ${{(! github.event.pull_request.merged) || (github.event.pull_request.merged && ! contains(github.head_ref, 'release/'))}}
commit: ${{steps.lasttag.outputs.commit}}
makeLatest: true
tag: ${{steps.lasttag.outputs.version}}