|
| 1 | +name: Source Plugin CrowdStrike Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "plugins/source/crowdstrike/**" |
| 7 | + - ".github/workflows/source_crowdstrike.yml" |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + paths: |
| 12 | + - "plugins/source/crowdstrike/**" |
| 13 | + - ".github/workflows/source_crowdstrike.yml" |
| 14 | + |
| 15 | +jobs: |
| 16 | + resolve-runner: |
| 17 | + timeout-minutes: 5 |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + runner: ${{ steps.resolve.outputs.runner }} |
| 21 | + steps: |
| 22 | + - name: Check if should use large runner |
| 23 | + id: large-runner |
| 24 | + # We want to speed runs on the main branch which prime the cache |
| 25 | + # We allow large runners only in this case to prevent forks from abusing them (it's enforced via runner groups access rules) |
| 26 | + # IF YOU WANT TO USE A LARGE RUNNER YOU NEED TO ADD THE WORKFLOW TO THE `CloudQuery releases` GROUP IN https://github.com/organizations/cloudquery/settings/actions/runner-groups |
| 27 | + if: github.event_name == 'push' |
| 28 | + run: | |
| 29 | + echo "runner=cloudquery-release-runner" >> $GITHUB_OUTPUT |
| 30 | + - name: Resolve runner |
| 31 | + id: resolve |
| 32 | + run: | |
| 33 | + RUNNER=${{ steps.large-runner.outputs.runner }} |
| 34 | + echo "runner=${RUNNER:-"ubuntu-latest"}" >> $GITHUB_OUTPUT |
| 35 | + plugins-source-crowdstrike: |
| 36 | + timeout-minutes: 30 |
| 37 | + name: "plugins/source/crowdstrike" |
| 38 | + needs: [resolve-runner] |
| 39 | + runs-on: ${{ needs.resolve-runner.outputs.runner }} |
| 40 | + defaults: |
| 41 | + run: |
| 42 | + working-directory: ./plugins/source/crowdstrike |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v3 |
| 45 | + with: |
| 46 | + fetch-depth: 2 |
| 47 | + - name: Set up Go 1.x |
| 48 | + uses: actions/setup-go@v3 |
| 49 | + with: |
| 50 | + go-version-file: plugins/source/crowdstrike/go.mod |
| 51 | + cache: true |
| 52 | + cache-dependency-path: plugins/source/crowdstrike/go.sum |
| 53 | + - name: golangci-lint |
| 54 | + uses: golangci/golangci-lint-action@v3 |
| 55 | + with: |
| 56 | + version: v1.50.1 |
| 57 | + working-directory: plugins/source/crowdstrike |
| 58 | + args: "--config ../../.golangci.yml" |
| 59 | + - name: Get dependencies |
| 60 | + run: go get -t -d ./... |
| 61 | + - name: Build |
| 62 | + run: go build . |
| 63 | + - name: Test |
| 64 | + run: make test |
| 65 | + - name: gen |
| 66 | + if: github.event_name == 'pull_request' |
| 67 | + run: make gen |
| 68 | + - name: Fail if generation updated files |
| 69 | + if: github.event_name == 'pull_request' |
| 70 | + run: test "$(git status -s | wc -l)" -eq 0 |
| 71 | + validate-release: |
| 72 | + timeout-minutes: 30 |
| 73 | + needs: [resolve-runner] |
| 74 | + runs-on: ${{ needs.resolve-runner.outputs.runner }} |
| 75 | + env: |
| 76 | + CGO_ENABLED: 0 |
| 77 | + steps: |
| 78 | + - name: Checkout |
| 79 | + if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push' |
| 80 | + uses: actions/checkout@v3 |
| 81 | + - uses: actions/cache@v3 |
| 82 | + if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push' |
| 83 | + with: |
| 84 | + path: | |
| 85 | + ~/.cache/go-build |
| 86 | + ~/go/pkg/mod |
| 87 | + key: ${{ runner.os }}-go-1.19.3-release-cache-${{ hashFiles('plugins/source/crowdstrike/go.sum') }} |
| 88 | + restore-keys: | |
| 89 | + ${{ runner.os }}-go-1.19.3-release-cache-plugins-source-crowdstrike |
| 90 | + - name: Set up Go |
| 91 | + if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push' |
| 92 | + uses: actions/setup-go@v3 |
| 93 | + with: |
| 94 | + go-version-file: plugins/source/crowdstrike/go.mod |
| 95 | + - name: Install GoReleaser |
| 96 | + if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push' |
| 97 | + uses: goreleaser/goreleaser-action@v3 |
| 98 | + with: |
| 99 | + distribution: goreleaser-pro |
| 100 | + version: latest |
| 101 | + install-only: true |
| 102 | + - name: Run GoReleaser Dry-Run |
| 103 | + if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push' |
| 104 | + run: goreleaser release --snapshot --rm-dist --skip-validate --skip-publish --skip-sign -f ./plugins/source/crowdstrike/.goreleaser.yaml |
| 105 | + env: |
| 106 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
0 commit comments