Skip to content

[QT-602] Further optimize scenario listing and sampling #89

[QT-602] Further optimize scenario listing and sampling

[QT-602] Further optimize scenario listing and sampling #89

Workflow file for this run

---
name: build
on:
# Run the build workflow manually from GitHub Actions menu
workflow_dispatch:
# Run the build workflow on merge to main
push:
# branches:
# - main # TODO: REMOVE BEFORE MERGE
env:
PKG_NAME: "enos"
jobs:
product-metadata:
runs-on: linux
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
product-version: ${{ steps.product-metadata.outputs.product-version }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- id: product-metadata
run: |
make version
echo "product-version=$(make version)" >> "$GITHUB_OUTPUT"
- id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@main
with:
version: ${{ steps.product-metadata.outputs.product-version }}
product: ${{ env.PKG_NAME }}
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}
build:
needs: product-metadata
runs-on: linux
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
fail-fast: true
name: Go ${{ matrix.goos }} ${{ matrix.goarch }} build
env:
GOPRIVATE: 'github.com/hashicorp/*'
TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
outputs:
artifact-name: ${{ steps.build.outputs.artifact-name }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: .go-version
# We do a three stage build with two profiling steps for max pgo benefit.
- uses: ./.github/actions/build
name: Standard build
with:
bundle: false
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
version: ${{ needs.product-metadata.outputs.product-version }}
- uses: ./.github/actions/profile-build
name: Profile standard build
- uses: ./.github/actions/build
name: PGO build
with:
bundle: false
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
version: ${{ needs.product-metadata.outputs.product-version }}
- uses: ./.github/actions/profile-build
name: Profile PGO build
- uses: ./.github/actions/build
name: Final build with all optimizations
id: build
with:
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
version: ${{ needs.product-metadata.outputs.product-version }}
- name: Upload Artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ env.PKG_NAME }}_${{ needs.product-metadata.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.product-metadata.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
retention-days: 1
- if: ${{ matrix.goos == 'linux' }}
uses: hashicorp/actions-packaging-linux@v1
with:
name: ${{ github.event.repository.name }}
description: "enos CLI package"
arch: ${{ matrix.goarch }}
version: ${{ needs.product-metadata.outputs.product-version }}
maintainer: "HashiCorp"
homepage: "https://github.com/hashicorp/enos"
license: "MPL-2.0"
binary: "dist/${{ env.PKG_NAME }}"
deb_depends: "openssl"
rpm_depends: "openssl"
- name: Set Package Names
if: ${{ matrix.goos == 'linux' }}
run: |
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> "$GITHUB_ENV"
echo "DEB_PACKAGE=$(basename out/*.deb)" >> "$GITHUB_ENV"
- name: Upload RHEL Packages
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ matrix.goos == 'linux' }}
with:
name: ${{ env.RPM_PACKAGE }}
path: out/${{ env.RPM_PACKAGE }}
- name: Upload Debian Packages
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ matrix.goos == 'linux' }}
with:
name: ${{ env.DEB_PACKAGE }}
path: out/${{ env.DEB_PACKAGE }}
build-docker:
name: Docker ${{ matrix.arch }} build
needs:
- product-metadata
- build
runs-on: linux
strategy:
matrix:
arch: ["arm64", "amd64"]
env:
repo: ${{github.event.repository.name}}
version: ${{needs.product-metadata.outputs.product-version}}
GOPRIVATE: 'github.com/hashicorp/*'
TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: hashicorp/actions-docker-build@v1
with:
version: ${{env.version}}
target: default
arch: ${{matrix.arch}}
tags: |
docker.io/hashicorp/${{env.repo}}:${{env.version}}
986891699432.dkr.ecr.us-east-1.amazonaws.com/hashicorp/${{env.repo}}:${{env.version}}
validate-artifact:
name: Validate Artifact
needs: [build, product-metadata]
uses: hashicorp/enos/.github/workflows/validate.yml@main
with:
artifact-name: "enos_${{ needs.product-metadata.outputs.product-version }}_linux_amd64.zip"
secrets:
ENOS_CI_SSH_PRIVATE_KEY: ${{ secrets.ENOS_CI_SSH_PRIVATE_KEY }}