Skip to content

Commit

Permalink
build: profile enos scenario validate
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Cragun <[email protected]>
  • Loading branch information
ryancragun committed Sep 15, 2023
1 parent 547ee1a commit fa79f07
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
30 changes: 22 additions & 8 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,48 @@ inputs:
goos:
description: the GOOS value
required: true
pgo:
description: build with profile guided optimization
default: false
version:
description: the version of the package
required: true

outputs:
artifact-name:
description: where the built artifact is located
value: ${{ steps.build.outputs.artifact-name }}
value: ${{ steps.prepare.outputs.artifact-name }}
artifact-path:
description: where the built artifact is located
value: ${{ steps.build.outputs.artifact-path }}
value: ${{ steps.prepare.outputs.artifact-path }}

runs:
using: composite
steps:
- name: Build
id: build
- name: prepare
id: prepare
env:
ARTIFACT_NAME: ${{ env.PKG_NAME}}_${{ inputs.version }}_${{ inputs.goos }}_${{ inputs.goarch }}.zip
GOARCH: ${{ inputs.goarch }}
GOOS: ${{ inputs.goos }}
shell: bash
run: |
mkdir -p dist out
make
echo "artifact-name=${{ env.ARTIFACT_NAME }}" >> "$GITHUB_OUTPUT"
echo "artifact-path=out/${{ env.ARTIFACT_NAME }}" >> "$GITHUB_OUTPUT"
- if: ${{ inputs.pgo != 'true' }}
name: build standard
env:
GOARCH: ${{ inputs.goarch }}
GOOS: ${{ inputs.goos }}
shell: bash
run: make build
- if: ${{ inputs.pgo == 'true' }}
name: build pgo
env:
GOARCH: ${{ inputs.goarch }}
GOOS: ${{ inputs.goos }}
shell: bash
run: make build-profile
- if: ${{ inputs.bundle == 'true' }}
name: Bundle
shell: bash
run: zip -r -j ${{ steps.build.outputs.artifact-path }} dist/
run: zip -r -j ${{ steps.prepare.outputs.artifact-path }} dist/
6 changes: 4 additions & 2 deletions .github/actions/profile-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ runs:
mv cpu.pprof cpu.pprof.scenario.list
${{ inputs.build-path }} scenario sample observe complex --max 10 --chdir ./acceptance/scenarios/build_pgo/ --profile
mv cpu.pprof cpu.pprof.sample.observe
go tool pprof -proto cpu.pprof.scenario.list cpu.pprof.sample.observe > ${{ inputs.profile-out }}
${{ inputs.build-path }} scenario validate --chdir ./acceptance/scenarios/build_pgo/ --profile
mv cpu.pprof cpu.pprof.validate
go tool pprof -proto cpu.pprof.scenario.list cpu.pprof.sample.observe cpu.pprof.validate > ${{ inputs.profile-out }}
- if: ${{ inputs.merge-to-default == 'true' }}
name: merge-to-default
shell: bash
run: |
if test -f default.pgo; then
cp default.pgo default.pprof
go tool pprof -proto ${{ inputs.profile-out }} -proto default.pprof > default.pgo
go tool pprof -proto ${{ inputs.profile-out }} default.pprof > default.pgo
exit 0
fi
cp ${{ inputs.profile-out }} default.pgo
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
bundle: false
goarch: amd64
goos: linux
pgo: true
version: ${{ steps.product-metadata.outputs.product-version }}
- uses: ./.github/actions/profile-build
id: final-profile
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
with:
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
pgo: true
version: ${{ needs.product-metadata.outputs.product-version }}
- name: Upload Artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ generate-proto:
build:
CGO_ENABLED=0 go build ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -o dist/${BINARY} ./command/enos

.PHONY: build-profile
build-profile:
CGO_ENABLED=0 go build ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -pgo=default.pgo -o dist/${BINARY} ./command/enos

.PHONY: build-race
build-race:
${GORACE} go build -race ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -o dist/${BINARY} ./command/enos
Expand Down

0 comments on commit fa79f07

Please sign in to comment.