Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert porter/porter to GitHub Actions #2879

Merged
merged 14 commits into from
Jan 22, 2024
172 changes: 172 additions & 0 deletions .github/workflows/porter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: porter/porter
on:
pull_request:
branches:
- main
env:
GOCACHE: "${{ runner.workspace }}/.cache/go-build/"
GOCACHE_KEY: v3 | go-build | "${{ runner.os }}" | go.sum
GOCACHE_RESTOREKEYS: |
v3 | go-build | "${{ runner.os }}"
v3 | go-build | "${{ runner.os }}" | go.sum
GOMODCACHE: "/home/vsts/go/pkg/mod"
GOMODCACHE_KEY: v4 | go-pkg | "${{ runner.os }}" | go.sum
GOMODCACHE_RESTOREKEYS: |
v4 | go-pkg | "${{ runner.os }}"
v4 | go-pkg | "${{ runner.os }}" | go.sum
GOVERSION: 1.20.7
GOXCACHE_KEY: v3 | go-xbuild | "${{ runner.os }}" | go.sum
GOXCACHE_RESTOREKEYS: |
v3 | go-xbuild | "${{ runner.os }}"
v3 | go-xbuild | "${{ runner.os }}" | go.sum
jobs:
Setup-pr_type:
name: Determine PR Type
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/[email protected]
- name: Is Doc Only?
id: BUILD
run: "./build/doc-only-build.sh"
shell: bash
Validate-build:
name: Native Compile
needs:
- Setup-pr_type
runs-on: ubuntu-latest
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
steps:
- name: checkout
uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Configure Agent
run: go run mage.go ConfigureAgent
- name: Native Build
run: mage build
shell: bash
- name: Publish Native Binaries
uses: actions/[email protected]
with:
name: build-bin
path: "${{ github.workspace }}/bin"
Validate-xbuild:
name: Cross Compile
needs:
- Setup-pr_type
runs-on: ubuntu-latest
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
steps:
- name: checkout
uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Configure Agent
run: go run mage.go ConfigureAgent
- name: Cross Compile
run: mage XBuildAll
shell: bash
- name: Publish Release Binaries
uses: actions/[email protected]
with:
name: xbuild-bin
path: "${{ github.workspace }}/bin"
Validate-unit_test:
name: Unit Test
needs:
- Setup-pr_type
runs-on: ubuntu-latest
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
steps:
- name: checkout
uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Configure Agent
run: go run mage.go ConfigureAgent
- name: Unit Test
run: mage TestUnit
shell: bash
Validate-VetLint:
name: Vet and Lint
needs:
- Setup-pr_type
runs-on: ubuntu-latest
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
steps:
- name: checkout
uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Configure Agent
run: go run mage.go ConfigureAgent
- name: Vet
run: mage Vet
shell: bash
- name: Lint
run: mage Lint
shell: bash
Validate-build_docker:
needs:
- Validate-xbuild
- Setup-pr_type
runs-on: ubuntu-latest
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
steps:
- name: checkout
uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Download Cross-Compiled Porter Binaries
uses: actions/[email protected]
with:
name: xbuild-bin
path: bin
- name: Setup Bin
run: go run mage.go ConfigureAgent UseXBuildBinaries
- name: Build Docker Images
run: mage BuildImages
Validate-smoke_test:
name: Run smoke tests on
needs:
- Validate-xbuild
- Setup-pr_type
runs-on:
- self-hosted
- "${{ matrix.vmImage }}"
if: success() && needs.Setup-pr_type.outputs['pr_type.BUILD.DOCS_ONLY'] == 'false'
strategy:
matrix:
include:
- poolName: Azure Pipelines
vmImage: ubuntu-latest
steps:
- name: checkout
uses: actions/[email protected]
- name: Download Cross-Compiled Porter Binaries
uses: actions/[email protected]
with:
name: xbuild-bin
path: bin
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}" # The Go version to download (if necessary) and use.
- run: go version
- name: Windows Cache Prep
if: env.poolName == 'windows'
run: attrib -r ${{ env.GOMODCACHE }}/*.* /s
- name: Configure Agent
run: go run mage.go ConfigureAgent UseXBuildBinaries
- name: Run Smoke Tests
run: mage -v TestSmoke