Skip to content

Commit

Permalink
test: add workflow to make sure importing Zarf works
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <philip.laine@gmail.com>
  • Loading branch information
phillebaba committed Aug 13, 2024
1 parent 51fcc03 commit d4610ce
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test Import
on:
pull_request:

permissions:
contents: read

# Abort prior jobs in the same workflow / PR
concurrency:
group: import-${{ github.ref }}
cancel-in-progress: true

jobs:
validate-unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true

- name: Run test Go program that imports Zarf
run: |
COMMIT_SHA=$(git rev-parse HEAD)
cd $(mktemp -d)
echo $GO_MAIN > main.go
go mod init github.com/zarf-dev/test-import
go mod tidy
go mod edit -replace github.com/zarf-dev/zarf=github.com/${{ github.repository }}@${COMMIT_SHA:0:12}
go mod tidy
cat go.mod | grep -q ${COMMIT_SHA:0:12}
go run main.go
env:
GO_MAIN: |
package main
import (
"fmt"
"github.com/zarf-dev/zarf/src/api/v1alpha1"
"github.com/zarf-dev/zarf/src/pkg/packager"
)
func main() {
fmt.Println(packager.Packager{})
fmt.Println(v1alpha1.ZarfComponent{})
}

0 comments on commit d4610ce

Please sign in to comment.