Merge pull request #133 from wasmCloud/renovate/golang.orgx #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Component / Go | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- '.github/workflows/component-go.yaml' | |
- 'component/**' | |
- 'examples/component/**' | |
pull_request: | |
branches: ["main"] | |
paths: | |
- '.github/workflows/component-go.yaml' | |
- 'component/**' | |
- 'examples/component/**' | |
env: | |
TINYGO_VERSION: "0.33.0" | |
GOLANGCI_VERSION: "v1.61" | |
WASH_VERSION: "0.37.0" | |
WASM_TOOLS_VERSION: "1.220.0" | |
permissions: | |
contents: read | |
defaults: | |
run: | |
working-directory: ./component | |
jobs: | |
lint: | |
# Context: https://github.com/golangci/golangci-lint-action/blob/v6.1.1/README.md#annotations | |
permissions: | |
# Required: allow read access to the content for analysis. | |
contents: read | |
# Optional: allow write access to checks to allow the action to annotate code in the PR. | |
checks: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 | |
with: | |
version: ${{ env.GOLANGCI_VERSION }} | |
working-directory: ./component | |
- uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0 | |
with: | |
tool: ${{ format('wasm-tools@{0}', env.WASM_TOOLS_VERSION) }} | |
- name: Go generate | |
run: | | |
go generate ./... | |
if ! test -z "$(git status --porcelain)"; then | |
echo "Go generate modified files. Please run go generate and commit the changes." | |
git status | |
exit 1 | |
fi | |
sdk-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version-file: "./component/go.mod" | |
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7 # v2.0.0 | |
with: | |
tinygo-version: ${{ env.TINYGO_VERSION }} | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v ./... | |
examples: | |
# Context: https://github.com/golangci/golangci-lint-action/blob/v6.1.1/README.md#annotations | |
permissions: | |
# Required: allow read access to the content for analysis. | |
contents: read | |
# Optional: allow write access to checks to allow the action to annotate code in the PR. | |
checks: write | |
strategy: | |
fail-fast: false | |
matrix: | |
example: | |
- http-server | |
- http-client | |
- http-password-checker | |
- invoke | |
- sqldb-postgres-query | |
tinygo-version: | |
- "0.33.0" | |
- "0.34.0" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version-file: "./examples/component/${{ matrix.example }}/go.mod" | |
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7 # v2.0.0 | |
with: | |
tinygo-version: ${{ matrix.tinygo-version }} | |
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 | |
with: | |
version: ${{ env.GOLANGCI_VERSION }} | |
working-directory: "./examples/component/${{ matrix.example }}" | |
- uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0 | |
with: | |
tool: ${{ format('wash@{0},wasm-tools@{1}', env.WASH_VERSION, env.WASM_TOOLS_VERSION) }} | |
- name: Go generate | |
run: | | |
go generate ./... | |
if ! test -z "$(git status --porcelain)"; then | |
echo "Go generate modified files. Please run go generate and commit the changes." | |
git status | |
exit 1 | |
fi | |
- name: wash build | |
working-directory: "./examples/component/${{ matrix.example }}" | |
run: | | |
wash build | |
- name: run tests | |
working-directory: "./examples/component/${{ matrix.example }}" | |
run: go test ./... | |
# Run the wadm file and make sure it deploys | |
- name: test component load | |
shell: bash | |
working-directory: "./examples/component/${{ matrix.example }}" | |
# TODO: Add a test to the matrix for testing the running component (i.e. with `curl` or `wash call`) | |
run: | | |
set -xe | |
wash up -d --wadm-manifest wadm.yaml; | |
sleep 1; | |
TRIES=0 | |
while [[ $(wash get inventory --output=json | jq '.inventories[0].components | length') -eq 0 ]] ; do | |
if [[ $TRIES -gt 10 ]]; then | |
echo "❌ failed to find component in inventory output after deploying example manifest"; | |
exit -1; | |
fi | |
TRIES=$((TRIES+1)); | |
sleep 1; | |
done; | |
echo "✅ successfully started at least one component"; | |
wash app delete wadm.yaml; | |
wash down --all; | |
exit 0; |