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

ci(i): Add YAML linter #2241

Merged
merged 7 commits into from
Jan 23, 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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ updates:
labels:
- "dependencies"
commit-message:
prefix: "bot"
prefix: "bot"
2 changes: 1 addition & 1 deletion .github/workflows/build-then-deploy-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- name: Terraform validation
run: terraform validate -no-color

- name: List workspaces
- name: List workspaces
run: ls workspaces

- name: Terraform Apply
Expand Down
35 changes: 19 additions & 16 deletions .github/workflows/combine-bot-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ on:
default: 'dependabot'

mustBeGreen:
description: 'Only combine PRs that are green (status is success). Set to false if repo does not run checks'
description: 'Only combine PRs that are green (status is success). Keep false if repo does not run checks'
type: boolean
required: true
default: true
default: false

combineBranchName:
description: 'Name of the branch to combine PRs into'
Expand All @@ -35,7 +35,7 @@ on:
ignoreLabel:
description: 'Exclude PRs with this label'
required: true
default: 'nocombine'
default: 'DO NOT MERGE'

jobs:
combine-bot-prs:
Expand All @@ -44,12 +44,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/github-script@v6
- name: Set current date as env variable
run: echo "CURRENT_DATE=$(date +'%d-%m-%Y')" >> ${GITHUB_ENV}

- name: Create combined pr
id: create-combined-pr

name: Create combined pr

uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -66,7 +66,7 @@ jobs:
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
console.log('Branch matched prefix: ' + branch);
let statusOK = true;
if(${{ github.event.inputs.mustBeGreen }}) {
if (${{ github.event.inputs.mustBeGreen }}) {
console.log('Checking green status: ' + branch);
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
repository(owner: $owner, name: $repo) {
Expand All @@ -92,25 +92,28 @@ jobs:
const [{ commit }] = result.repository.pullRequest.commits.nodes;
const state = commit.statusCheckRollup.state
console.log('Validating status: ' + state);
if(state != 'SUCCESS') {
if (state != 'SUCCESS') {
console.log('Discarding ' + branch + ' with status ' + state);
statusOK = false;
}
}
console.log('Checking labels: ' + branch);
const labels = pull['labels'];
for(const label of labels) {
for (const label of labels) {
const labelName = label['name'];
console.log('Checking label: ' + labelName);
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
if (labelName == '${{ github.event.inputs.ignoreLabel }}') {
console.log('Discarding ' + branch + ' with label ' + labelName);
statusOK = false;
}
}
if (statusOK) {
console.log('Adding branch to array: ' + branch);
const prString = '#' + pull['number'] + ' ' + pull['title'];
branchesAndPRStrings.push({ branch, prString });
branchesAndPRStrings.push({
branch,
prString
});
baseBranch = pull['base']['ref'];
baseBranchSHA = pull['base']['sha'];
}
Expand All @@ -135,7 +138,7 @@ jobs:

let combinedPRs = [];
let mergeFailedPRs = [];
for(const { branch, prString } of branchesAndPRStrings) {
for (const { branch, prString } of branchesAndPRStrings) {
try {
await github.rest.repos.merge({
owner: context.repo.owner,
Expand All @@ -153,15 +156,15 @@ jobs:

console.log('Creating combined PR');
const combinedPRsString = combinedPRs.join('\n');
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString;
if(mergeFailedPRs.length > 0) {
let body = '✅ This PR was created by combining the following PRs:\n' + combinedPRsString;
if (mergeFailedPRs.length > 0) {
const mergeFailedPRsString = mergeFailedPRs.join('\n');
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString
}
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'bot: Combined PRs',
title: 'bot: Update dependencies (bulk dependabot PRs) ${CURRENT_DATE}',
head: '${{ github.event.inputs.combineBranchName }}',
base: baseBranch,
body: body
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ jobs:
github.event_name == 'pull_request' &&
github.base_ref == 'develop'
run: >
${GOPATH}/bin/benchstat -html -alpha 1.1 develop.txt current.txt | sed -n "/<body>/,/<\/body>/p" > comparison.html &&
${GOPATH}/bin/benchstat -html -alpha 1.1 develop.txt current.txt |
sed -n "/<body>/,/<\/body>/p" > comparison.html &&
./tools/scripts/pretty-benchstat-html.sh comparison.html > pretty-comparison.md

- name: Comment Benchmark Results on PR
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ permissions:
contents: read

jobs:
lint:
name: Lint job
lint-go:
name: Lint GoLang job

runs-on: ubuntu-latest

Expand All @@ -39,9 +39,8 @@ jobs:
go-version: "1.21"
check-latest: true

- name: Check linting through golangci-lint
- name: Run golangci-lint linter
uses: golangci/golangci-lint-action@v3

with:
# Required: the version of golangci-lint is required.
# Note: The version should not pick the patch version as the latest patch
Expand All @@ -68,3 +67,18 @@ jobs:
# anyways so there shouldn't be any linter errors anyways. The enforces us to
# always have a clean lint state.
only-new-issues: false

lint-yaml:
name: Lint YAML job

runs-on: ubuntu-latest

steps:
- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Run yamllint linter
uses: ibiqlik/action-yamllint@v3
with:
config_file: tools/configs/yamllint.yaml
file_or_dir: .
2 changes: 1 addition & 1 deletion .github/workflows/preview-ami-with-terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ jobs:
if: steps.terraform-plan.outcome == 'failure'
run: exit 1

- name: List workspaces
- name: List workspaces
run: ls workspaces
2 changes: 1 addition & 1 deletion .github/workflows/test-and-upload-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:

needs: run-tests

# Important to know:
# Important to know:
# - We didn't use `if: always()` here, so this job doesn't run if we manually canceled.
# - `if: success()` is always implied unless `always()` or `failure()` is specified.
if: success() || failure()
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/validate-containerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ jobs:

- name: Test Docker image
run: docker run --rm ${{ env.TEST_TAG }}

67 changes: 40 additions & 27 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ builds:
goarch:
- amd64
- arm64
# A build with the playground included.
# A build with the playground included.
- id: "defradb_playground"
main: ./cmd/defradb
flags:
Expand All @@ -27,30 +27,44 @@ builds:
goarch:
- amd64
- arm64

partial:
by: target

archives:
- id: defradb_playground
builds:
builds:
- defradb_playground
format: binary
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: '{{ .Binary }}_playground_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}{{- if .Arm }}v{{ .Arm }}{{ end }}'
name_template: >-
{{ .Binary }}_playground_{{ .Version }}_{{ .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
- id: defradb
builds:
builds:
- defradb
format: binary
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}{{- if .Arm }}v{{ .Arm }}{{ end }}'
name_template: >-
{{ .Binary }}_{{ .Version }}_{{ .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}

release:
target_commitish: '{{ .Commit }}'
header: |
DefraDB v{{ .Major }}.{{ .Minor }} is a major pre-production release. Until the stable version 1.0 is reached, the SemVer minor patch number will denote notable releases, which will give the project freedom to experiment and explore potentially breaking changes.
header: >
DefraDB v{{ .Major }}.{{ .Minor }} is a major pre-production release.
fredcarle marked this conversation as resolved.
Show resolved Hide resolved
Until the stable version 1.0 is reached, the SemVer minor patch number will denote notable releases,
which will give the project freedom to experiment and explore potentially breaking changes.

To get a full outline of the changes, we invite you to review the official changelog below.
This release does include a Breaking Change to existing v{{ .Major }}.{{ .Minor }}.x databases.
If you need help migrating an existing deployment, reach out at [email protected] or join
our Discord at https://discord.gg/w7jYQVJ/.

To get a full outline of the changes, we invite you to review the official changelog below. This release does include a Breaking Change to existing v{{ .Major }}.{{ .Minor }}.x databases. If you need help migrating an existing deployment, reach out at [email protected] or join our Discord at https://discord.gg/w7jYQVJ/.
name_template: "v{{ .Version }} Release"

changelog:
Expand Down Expand Up @@ -85,21 +99,20 @@ milestones:
name_template: "DefraDB v{{ .Major }}.{{ .Minor }}"

dockers:
- ids:
- "defradb_playground"
image_templates:
- "{{ .Env.GITHUB_REPOSITORY }}:latest"
- "{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
use: buildx
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.description=DefraDB is a Peer-to-Peer Edge Database."
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- "--platform=linux/amd64"
dockerfile: ./tools/goreleaser.containerfile

- ids:
- "defradb_playground"
image_templates:
- "{{ .Env.GITHUB_REPOSITORY }}:latest"
- "{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
use: buildx
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.description=DefraDB is a Peer-to-Peer Edge Database."
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- "--platform=linux/amd64"
dockerfile: ./tools/goreleaser.containerfile
Loading
Loading