Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI jobs #12

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
Comment on lines -37 to -38

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any context on why this didn't work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does work and we use it for some other jobs, but for linting we don't need to check out the history. we just need the commit. this is also related to why we disarm the go:embed stuff. We can just lint the code without having to build the provider and generate code, etc.

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21
cache: false
# This step is performed because we some of the go:embed files are generated. However, we
# can lint the code without having to do a full build/generate cycle. Therefore we
# just make them do nothing.
- name: disarm go:embed directives to enable lint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment for why we're doing this

continue-on-error: true # this fails if there are no go:embed directives
run: |
git grep -l 'go:embed' -- provider | xargs sed -i 's/go:embed/ goembed/g'
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.55.2
working-directory: provider
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
tag: v0.0.46
repo: pulumi/pulumictl
- name: Install Pulumi CLI
uses: pulumi/actions@v5
with:
pulumi-version: ^3
- name: Lint Provider
run: make lint_provider
args: -c ../.golangci.yml

test:
runs-on: ubuntu-latest
Expand All @@ -79,7 +74,7 @@ jobs:
with:
pulumi-version: ^3
- name: Test Provider
run: make test_provider
run: make provider test_provider

build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -132,7 +127,8 @@ jobs:
gradle-version: ${{ env.GRADLEVERSION }}
- name: Build SDK
run: make provider build_${{ matrix.language }}
# TODO: Check worktree clean
- name: Check generated code is up to date
run: ./scripts/check_for_diffs.sh
strategy:
fail-fast: true
matrix:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ tfgen: install_plugins
PATH=${PWD}/.pulumi/bin:$$PATH PULUMI_CONVERT=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER)
(cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go)

.PHONY: test_generate
test_generate:
./scripts/check_for_diffs.sh

bin/pulumi-java-gen:
pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java

Expand Down
17 changes: 17 additions & 0 deletions scripts/check_for_diffs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

echo "--- :golang: go mod tidy"
(cd provider && go mod tidy)

echo "--- :git: Testing generate code is up to date"
# Enable debugging to see commands executed, if needed
# set -x

# Check if there are any changes or untracked files
if [ -n "$(git status --porcelain)" ]; then
echo "^^^ +++"
git status --porcelain
git diff
echo "Check git status + diff above, there are changed or untracked files"
exit 1
fi
Loading