Skip to content

Commit

Permalink
Fix workflows (#276)
Browse files Browse the repository at this point in the history
* Fix workflows

* POWERPIPE_UPDATE_CHECK: false
  • Loading branch information
pskrbasu authored Mar 18, 2024
1 parent dc11bbb commit e75b73b
Show file tree
Hide file tree
Showing 3 changed files with 330 additions and 46 deletions.
169 changes: 163 additions & 6 deletions .github/workflows/01-powerpipe-pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,176 @@ env:
ORG: turbot
CORE_REPO: us-docker.pkg.dev/steampipe/steampipe
ASSET_IMAGE_NAME: assets
POWERPIPE_UPDATE_CHECK: false
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: powerpipe
ref: ${{ github.event.ref }}

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v4
with:
repository: turbot/pipe-fittings
path: pipe-fittings

# this is required, check golangci-lint-action docs
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false # setup-go v4 caches by default, do not change this parameter, check golangci-lint-action doc: https://github.com/golangci/golangci-lint-action/pull/704

- name: Build
run: |-
cd powerpipe
make release-dry-run
- name: Move build artifacts
run: |
ls -al $GITHUB_WORKSPACE/powerpipe
sudo chown -R runner:docker $GITHUB_WORKSPACE/powerpipe/dist
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/powerpipe/dist/powerpipe.linux.amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/powerpipe/dist/powerpipe.darwin.amd64.tar.gz ~/artifacts/darwin.tar.gz
- 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.tar.gz
if-no-files-found: error

acceptance_test:
name: Test
needs: goreleaser
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
test_block:
- "check"
- "dashboard"
- "mod_install"
- "sp_files"
- "mod_vars"
- "snapshot"
- "dashboard_parsing_validation"
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
path: powerpipe
ref: ${{ github.event.ref }}

- uses: actions/setup-go@v5
with:
go-version: 1.21
cache: false

- 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
tar -xf ~/artifacts/darwin.tar.gz -C ~/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: Install Steampipe(Darwin)
if: ${{ matrix.platform == 'macos-latest' }}
run: |
brew install turbot/tap/steampipe
steampipe -v
acceptance_tests:
name: Run Acceptance Tests
uses: turbot/powerpipe/.github/workflows/11-test-acceptance.yaml@272-save-money
with:
test_platforms: '["ubuntu-latest", "macos-latest"]'
- name: Install Steampipe(Linux)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo /bin/sh -c "$(curl -fsSL https://steampipe.io/install/steampipe.sh)"
steampipe -v
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/powerpipe/tests/acceptance/lib/bats-core/libexec" >> $GITHUB_ENV
- name: Go install jd
run: |
go install github.com/josephburnett/jd@latest
- name: Start steamipipe service
run: |
steampipe service start
- name: Run Test Suite
id: run-test-suite
timeout-minutes: 15
continue-on-error: true
run: |
chmod +x $GITHUB_WORKSPACE/powerpipe/tests/acceptance/run.sh
$GITHUB_WORKSPACE/powerpipe/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
echo "exit_code=$(echo $?)" >> $GITHUB_OUTPUT
echo ">> here"
# 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
- name: Stop steampipe service
run: |
steampipe service stop
build_assets:
name: Build and Release Dashboard Assets
needs: [acceptance_tests]
needs: [acceptance_test]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
Expand Down
170 changes: 165 additions & 5 deletions .github/workflows/02-powerpipe-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
ORG: turbot
CORE_REPO: us-docker.pkg.dev/steampipe/steampipe
ASSET_IMAGE_NAME: assets
POWERPIPE_UPDATE_CHECK: false
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
VERSION: ${{ github.event.inputs.version }}

Expand Down Expand Up @@ -39,14 +40,173 @@ jobs:
with:
ref: ${{ github.event.ref }}

acceptance_tests:
name: Run Acceptance Tests
needs: [verify_input]
uses: turbot/powerpipe/.github/workflows/11-test-acceptance.yaml@main
goreleaser:
needs: verify_input
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: powerpipe
ref: ${{ github.event.ref }}

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v4
with:
repository: turbot/pipe-fittings
path: pipe-fittings

# this is required, check golangci-lint-action docs
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false # setup-go v4 caches by default, do not change this parameter, check golangci-lint-action doc: https://github.com/golangci/golangci-lint-action/pull/704

- name: Build
run: |-
cd powerpipe
make release-dry-run
- name: Move build artifacts
run: |
ls -al $GITHUB_WORKSPACE/powerpipe
sudo chown -R runner:docker $GITHUB_WORKSPACE/powerpipe/dist
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/powerpipe/dist/powerpipe.linux.amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/powerpipe/dist/powerpipe.darwin.amd64.tar.gz ~/artifacts/darwin.tar.gz
- 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.tar.gz
if-no-files-found: error

acceptance_test:
name: Test
needs: goreleaser
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
test_block:
- "check"
- "dashboard"
- "mod_install"
- "sp_files"
- "mod_vars"
- "snapshot"
- "dashboard_parsing_validation"
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
path: powerpipe
ref: ${{ github.event.ref }}

- uses: actions/setup-go@v5
with:
go-version: 1.21
cache: false

- 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
tar -xf ~/artifacts/darwin.tar.gz -C ~/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: Install Steampipe(Darwin)
if: ${{ matrix.platform == 'macos-latest' }}
run: |
brew install turbot/tap/steampipe
steampipe -v
- name: Install Steampipe(Linux)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo /bin/sh -c "$(curl -fsSL https://steampipe.io/install/steampipe.sh)"
steampipe -v
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/powerpipe/tests/acceptance/lib/bats-core/libexec" >> $GITHUB_ENV
- name: Go install jd
run: |
go install github.com/josephburnett/jd@latest
- name: Start steamipipe service
run: |
steampipe service start
- name: Run Test Suite
id: run-test-suite
timeout-minutes: 15
continue-on-error: true
run: |
chmod +x $GITHUB_WORKSPACE/powerpipe/tests/acceptance/run.sh
$GITHUB_WORKSPACE/powerpipe/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
echo "exit_code=$(echo $?)" >> $GITHUB_OUTPUT
echo ">> here"
# 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
- name: Stop steampipe service
run: |
steampipe service stop
build_assets:
name: Build and Release Dashboard Assets
needs: [acceptance_tests]
needs: [acceptance_test]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
Expand Down
Loading

0 comments on commit e75b73b

Please sign in to comment.