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

Release v1.4.0 #197

Merged
merged 10 commits into from
Feb 26, 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
88 changes: 5 additions & 83 deletions .github/workflows/go-test-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ on:
permissions:
contents: read

env:
REPORT_FILENAME:

jobs:
get-go-version:
runs-on: ubuntu-latest
Expand All @@ -43,7 +40,7 @@ jobs:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- run: |
echo "Testing with Go ${{ needs.get-go-version.outputs.go-version }}"
go test -race -count 1 ./... -timeout=3m
make unit-test

windows-go-tests:
needs:
Expand All @@ -55,96 +52,21 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
# Running unit tests directly with `go test` due to gofmt/gofumpt issues in Windows
- run: |
echo "Testing with Go ${{ needs.get-go-version.outputs.go-version }}"
go test -race -count 1 ./... -timeout=3m
go test -race -count 1 ./builder/linode/... -timeout=3m -v

linux-go-tests:
needs:
- get-go-version
runs-on: ubuntu-latest
env:
EXIT_STATUS: 0
name: Linux Go tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Set report filename
id: set-report-filename
run: |
report_filename=$(date +'%Y%m%d%H%M')_packer_test_report.xml
echo "REPORT_FILENAME=$report_filename" >> $GITHUB_ENV

- name: Run integration tests
run: |
- run: |
echo "Testing with Go ${{ needs.get-go-version.outputs.go-version }}"
if ! go test -race -count 1 ./... -timeout=3m -v | go-junit-report -set-exit-code > "$REPORT_FILENAME"; then
echo "EXIT_STATUS=1" >> $GITHUB_ENV
fi
cat "$REPORT_FILENAME"

- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: test-report-file
path: "${{ env.REPORT_FILENAME }}"

- name: Test Execution Status Handler
run: |
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Test execution contains failure(s), check Run Integration tests step above"
exit $EXIT_STATUS
else
echo "Tests passed!"
fi

process-upload-report:
needs: linux-go-tests
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/dev')
steps:
- name: Checkout code
uses: actions/checkout@v4

# Download the artifact generated by the 'linux-go-tests' job
- name: Download test report
uses: actions/download-artifact@v4
with:
name: test-report-file

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python deps
run: pip3 install requests wheel boto3

- name: Set release version env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

# Add additional information to XML report
- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python scripts/add_to_xml_test_report.py \
--branch_name "${{ env.RELEASE_VERSION }}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
--xmlfile "${filename}"

# Upload test results to the bucket
- name: Upload test results to bucket
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python3 scripts/test_report_upload_script.py "${filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}

make unit-test
2 changes: 1 addition & 1 deletion .github/workflows/go-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@v4
with:
only-new-issues: true
check-fmt:
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/integration-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Integration and Unit Tests

on:
push:
branches:
- 'main'
- 'dev'

env:
REPORT_FILENAME:

jobs:
integration-and-unit-tests:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/dev')
env:
EXIT_STATUS: 0
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Set report filename
id: set-report-filename
run: echo "REPORT_FILENAME=$(date +'%Y%m%d%H%M')_packer_test_report.xml" >> $GITHUB_ENV

- name: Run integration and unit tests
run: |
echo "Testing with Go ${{ needs.get-go-version.outputs.go-version }}"
if ! make test | go-junit-report -set-exit-code > "$REPORT_FILENAME"; then
echo "EXIT_STATUS=1" >> $GITHUB_ENV
fi
cat "$REPORT_FILENAME"
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

- name: Upload test report as artifact
uses: actions/upload-artifact@v4
with:
name: test-report-file
path: "${{ env.REPORT_FILENAME }}"

- name: Test Execution Status Handler
run: |
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Test execution contains failure(s), check Run Integration tests step above"
exit $EXIT_STATUS
else
echo "Tests passed!"
fi

process-upload-report:
runs-on: ubuntu-latest
needs:
- integration-and-unit-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'

- name: Download test report
uses: actions/download-artifact@v4
with:
name: test-report-file

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python dependencies
run: pip3 install requests wheel boto3

- name: Set release version env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python tod_scripts/add_to_xml_test_report.py \
--branch_name "${{ env.RELEASE_VERSION }}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
--xmlfile "${filename}"

- name: Upload test results to the bucket
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python3 tod_scripts/test_report_upload_script.py "${filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tod_scripts"]
path = tod_scripts
url = https://github.com/linode/TOD-test-report-uploader.git
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
timeout: 15m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down
2 changes: 2 additions & 0 deletions .web-docs/components/builder/linode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ can also be supplied to override the typical auto-generated key:
Please note that when you create a new Linode instance with a private image, you will
be required to setup a new root password.

- `cloud_init` (bool) - Whether the newly created image supports cloud-init.

#### Interface

This section outlines the fields configurable for a single interface object.
Expand Down
44 changes: 0 additions & 44 deletions GNUmakefile

This file was deleted.

73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
NAME=linode
BINARY=packer-plugin-${NAME}
COUNT?=1
UNIT_TEST_TARGET?=$(shell go list ./builder/...)
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
PACKER_SDC_REPO ?= github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc
.DEFAULT_GOAL = dev

# install is an alias of dev
.PHONY: install
install: dev

.PHONY: dev
dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}

.PHONY: build
build: fmtcheck
@go build -o ${BINARY}

.PHONY: test
test: dev fmtcheck acctest

.PHONY: install-packer-sdc
install-packer-sdc: ## Install packer sofware development command
@go install ${PACKER_SDC_REPO}@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}

.PHONY: plugin-check
plugin-check: install-packer-sdc build
@packer-sdc plugin-check ${BINARY}

.PHONY: unit-test
unit-test: dev
@go test -count $(COUNT) -v $(UNIT_TEST_TARGET) -timeout=10m

# int-test is an alias of acctest
.PHONY: int-test
int-test: acctest

.PHONY: acctest
acctest: dev
@PACKER_ACC=1 go test -count $(COUNT) ./... -v -timeout=100m

.PHONY: generate
generate: install-packer-sdc
@go generate ./...
@rm -rf .docs
@packer-sdc renderdocs -src "docs" -partials docs-partials/ -dst ".docs/"
@./.web-docs/scripts/compile-to-webdocs.sh "." ".docs" ".web-docs" "linode"
@rm -r ".docs"

.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

.PHONY: lint
lint: fmtcheck
@golangci-lint run

.PHONY: format
format:
@gofumpt -w .

.PHONY: deps
deps: install-packer-sdc
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install mvdan.cc/gofumpt@latest

.PHONY: clean
clean:
@rm -rf .docs
@rm -rf ./packer-plugin-linode
7 changes: 4 additions & 3 deletions builder/linode/builder_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const testBuilderAccBasic = `
{
"builders": [{
"type": "linode",
"region": "us-ord",
"region": "us-mia",
"instance_type": "g6-nanode-1",
"image": "linode/alpine3.9",
"ssh_username": "root"
"image": "linode/debian12",
"ssh_username": "root",
"cloud_init": true
}]
}
`
Loading