Files
steampipe/.github/workflows/test.yml
kaidaguerre fa18c8f0e2 Add support for node reuse. Update graph, flow and hierarchy to declare nodes and edges inline, rather than as a list of references. Closes #2871
Only top level resources can have with and param blocks. Closes #2872
Refactor resource and dashboard run hierarchies to use base impl structs. Closes #2873
2022-12-14 17:18:57 +00:00

219 lines
6.3 KiB
YAML

name: Steampipe Acceptance Tests
on:
pull_request:
env:
STEAMPIPE_UPDATE_CHECK: false
SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }}
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}
jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Fetching Go Cache Paths
id: go-cache-paths
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
# used to speedup go test
- name: Go Build Cache
id: build-cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
id: mod-cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Run CLI Unit Tests
run: |
go clean -testcache
go test -timeout 30s ./... -test.v
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist --snapshot --parallelism 2 --config=.acceptance.goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move build artifacts
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
- name: List Build Artifacts
run: ls -l ~/artifacts
- name: Save Linux Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-linux
path: ~/artifacts/linux.tar.gz
if-no-files-found: error
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-darwin
path: ~/artifacts/darwin.zip
if-no-files-found: error
acceptance_test:
name: Test
needs: goreleaser
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest]
test_block:
- "migration"
- "service_and_plugin"
- "search_path"
- "chaos_and_query"
- "dynamic_schema"
- "cache"
- "mod_install"
- "mod"
- "check"
- "performance"
- "workspace"
- "cloud"
- "exit_codes"
- "force_stop"
exclude:
- platform: macos-latest
test_block: migration
- platform: macos-latest
test_block: force_stop
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Prepare for downloads
id: prepare-for-downloads
run: |
mkdir ~/artifacts
- name: Download Linux Build Artifacts
uses: actions/download-artifact@v3
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: build-artifact-linux
path: ~/artifacts
- name: Download Darwin Build Artifacts
uses: actions/download-artifact@v3
if: ${{ matrix.platform == 'macos-latest' }}
with:
name: build-artifact-darwin
path: ~/artifacts
- name: Extract Darwin Artifacts and Install Binary
if: ${{ matrix.platform == 'macos-latest' }}
run: |
mkdir ~/build
unzip ~/artifacts/darwin.zip -d ~/build
- name: Extract Ubuntu Artifacts and Install Binary
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
mkdir ~/build
tar -xf ~/artifacts/linux.tar.gz -C ~/build
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/tests/acceptance/lib/bats/libexec" >> $GITHUB_ENV
- name: Install DB
id: install-db
continue-on-error: false
run: |
steampipe service start
steampipe plugin install chaos
steampipe service stop
- name: Run Test Suite
id: run-test-suite
timeout-minutes: 15
continue-on-error: true
run: |
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
$GITHUB_WORKSPACE/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
echo "exit_code=$(echo $?)" >> $GITHUB_OUTPUT
steampipe service stop --force
- name: Save Test Suite Logs
uses: actions/upload-artifact@v3
with:
name: test-logs
path: ~/.steampipe/logs
if-no-files-found: error
# This job checks whether the test suite has passed or not.
# Since the exit_code is set only when the bats test suite pass,
# we have added the if-conditional block
- name: Check Test Passed/Failed
if: ${{ success() }}
continue-on-error: false
run: |
if [ ${{ steps.run-test-suite.outputs.exit_code }} -eq 0 ]; then
exit 0
else
exit 1
fi
clean_up:
# let's clean up the artifacts.
# incase this step isn't reached,
# artifacts automatically expire after 90 days anyway
# refer:
# https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#downloading-and-deleting-artifacts-after-a-workflow-run-is-complete
name: Clean Up Artifacts
needs: acceptance_test
if: ${{ needs.acceptance_test.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Clean up Linux Build
uses: geekyeggo/delete-artifact@v2
with:
name: build-artifact-linux
failOnError: true
- name: Clean up Darwin Build
uses: geekyeggo/delete-artifact@v2
with:
name: build-artifact-darwin
failOnError: true
- name: Clean up Test Suite Logs
uses: geekyeggo/delete-artifact@v2
with:
name: test-logs
failOnError: true