github-action-benchmark icon indicating copy to clipboard operation
github-action-benchmark copied to clipboard

Error: Cannot read properties of undefined (reading 'Benchmark')

Open clicky opened this issue 3 years ago • 3 comments

I am using a self-hosted runner which runs Windows 10 x64 with all the latest updates for itself and the runner. I'm not sure why exactly but I keep getting this error, image

Can any one help me? YAML Below;

	  # Calls for run of BenchmarkDotNet project and sets bench_output / bench_cache
      - name: Run benchmark
        id: benchrun
        run: .\scripts\RunBench.ps1
        shell: powershell

      # Download previous benchmark result from cache (if exists)
      - name: Download previous benchmark data
        uses: actions/cache@v1
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark

      # Run `github-action-benchmark` action
      - name: Store benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          # What benchmark tool the output.txt came from
          tool: 'benchmarkdotnet'
          # Where the output from the benchmark tool is stored
          output-file-path: ${{ steps.benchrun.outputs.bench_output }}
          # Where the previous data file is stored
          external-data-json-path: ${{ steps.benchrun.outputs.bench_cache }}
          # Workflow will fail when an alert happens
          fail-on-alert: true          
          alert-threshold: "150%"
          # auto-push: true
          github-token: ${{ secrets.GITHUB_TOKEN }}
          comment-on-alert: true

clicky avatar Mar 11 '22 23:03 clicky

Hi @clicketyclackety

Are you able to share what is the result of the .\scripts\RunBench.ps1 script?

I'm not sure where exactly is this error occurring. There is no place in the source code that tries to access Benchmark property. Are you sure this error doesn't happen in the .\scripts\RunBench.ps1 script?

ktrz avatar Mar 14 '22 08:03 ktrz

Sure! I replaced the project name with <project> for some anonymity. Here is the workflow in Github Actions; image

And the YAML

---
name: BuildAndTest

on:
  pull_request:
    branches: [develop, 'develop/**']

jobs:
  build:
    runs-on: self-hosted

    steps:
      - uses: actions/checkout@v2
        name: Checkout Repo
        with:
          fetch-depth: 0

      - name: Validate DocStrings
        run: .\scripts\DocChecker.ps1  "origin/develop" ${{ github.sha }}
        shell: powershell

      - name: Setup MSBuild path
        uses: microsoft/[email protected]
        env:
          ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

      - name: Setup NuGet
        uses: NuGet/[email protected]
        env:
          ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

      - name: Restore NuGet Packages
        run: nuget restore <project>.sln

      - name: Build Projects
        run: .\scripts\BuildProjects.ps1
        shell: powershell
    
      - name: Run benchmark
        id: benchrun
        run: .\scripts\RunBench.ps1
        shell: powershell

      # Download previous benchmark result from cache (if exists)
      - name: Download previous benchmark data
        uses: actions/cache@v1
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark
        
      # Run `github-action-benchmark` action
      - name: Store benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          # What benchmark tool the output.txt came from
          tool: 'benchmarkdotnet'
          # Where the output from the benchmark tool is stored
          output-file-path: ${{ steps.benchrun.outputs.bench_output }}
          # Where the previous data file is stored
          external-data-json-path: ${{ steps.benchrun.outputs.bench_cache }}
          # Workflow will fail when an alert happens
          fail-on-alert: true          
          alert-threshold: "150%"
          github-token: ${{ secrets.GITHUB_TOKEN }}
          comment-on-alert: true

      # Upload the updated cache file for the next job by actions/cache
      - name: Upload new benchmark data
        uses: actions/cache@v1
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark

RunBench.ps1 output ; benchmarkoutput.txt

clicky avatar Mar 14 '22 16:03 clicky

I am trying to understand where are the output params set in the RunBench.ps1 but could find any references >> docs <<

By reading the script output I assume that your benchmark result is store in this file C:\Users\<user>\actions-runner\_work\<project>\<project>\BenchmarkDotNet.Artifacts\results\<project>.benchmarks.StringIt-report-custom.json. Could you verify that steps.benchrun.outputs.bench_output is properly pointing to this file and that the json file has similar shape to this example file?

ktrz avatar Mar 14 '22 20:03 ktrz