Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
air-31 committed Mar 26, 2024
1 parent 95d2d95 commit 53a922e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 57 deletions.
94 changes: 44 additions & 50 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,68 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: "../../operators/go.mod"

- name: Check linting
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.50.1
version: v1.54
working-directory: operators
args: --timeout=600s


gomodtidy:
name: Enforce go.mod tidiness
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Execute go mod tidy and check the outcome
working-directory: ./operators
run: |
go mod tidy
exit_code=$(git diff --exit-code)
exit ${exit_code}
- name: Issue a comment in case the of failure
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.CI_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
The `go.mod` and/or `go.sum` files appear not to be correctly tidied.
Please, rerun `go mod tidy` to fix the issues.
reactions: confused
if: |
failure() && github.event.pull_request.head.repo.full_name == github.repository
- name: Checkout
uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.head.sha }}"
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "../../operators/go.mod"

- name: Execute go mod tidy and check the outcome
working-directory: ./operators
run: |
go mod tidy
exit_code=$(git diff --exit-code)
exit ${exit_code}
- name: Issue a comment in case the of failure
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.CI_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
The `go.mod` and/or `go.sum` files appear not to be correctly tidied.
Please, rerun `go mod tidy` to fix the issues.
reactions: confused
if: |
failure() && github.event.pull_request.head.repo.full_name == github.repository
python-lint:
name: Lint python files
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
Expand All @@ -85,14 +83,13 @@ jobs:
- name: Check linting
uses: TrueBrain/actions-flake8@v2


markdown-lint:
name: Lint markdown files (check links validity)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
Expand All @@ -101,16 +98,15 @@ jobs:
- name: Check the validity of the links in the documentation
uses: gaurav-nelson/[email protected]
with:
use-quiet-mode: 'yes'

use-quiet-mode: "yes"

shell-lint:
name: Lint shell files
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
Expand All @@ -119,23 +115,22 @@ jobs:
- name: Run shellcheck
uses: azohra/[email protected]
with:
exclude-paths: "**/.husky/*-commit"

exclude-paths: "**/.husky/*-commit"

frontend-lint:
name: Lint frontend files
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Setup nodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14

Expand All @@ -147,21 +142,20 @@ jobs:
working-directory: ./frontend
run: yarn check-format-lint


qlkube-lint:
name: Lint qlkube files
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Setup nodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14

Expand Down
6 changes: 3 additions & 3 deletions operators/pkg/tenant-controller/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

Expand Down Expand Up @@ -173,8 +173,8 @@ var _ = Describe("Sandbox", func() {
Kind: "Tenant",
Name: tenant.Name,
UID: tenant.GetUID(),
BlockOwnerDeletion: pointer.Bool(true),
Controller: pointer.Bool(true),
BlockOwnerDeletion: ptr.To[bool](true),
Controller: ptr.To[bool](true),
}
sandboxNSname = types.NamespacedName{
Name: forge.CanonicalSandboxName(tenantName),
Expand Down
4 changes: 2 additions & 2 deletions operators/pkg/tenant-controller/tenant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (r *TenantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
}

if err = r.EnforceSandboxResources(ctx, &tn); err != nil {
klog.Error("Failed checking sandbox for tenant %s -> %s", tn.Name, err)
klog.Errorf("Failed checking sandbox for tenant %s -> %s", tn.Name, err)
tn.Status.SandboxNamespace.Created = false
tnOpinternalErrors.WithLabelValues("tenant", "sandbox-resources").Inc()
return ctrl.Result{}, err
Expand Down Expand Up @@ -334,7 +334,7 @@ func (r *TenantReconciler) checkNamespaceKeepAlive(ctx context.Context, tn *crow
// Attempt to get instances in current namespace
list := &crownlabsv1alpha2.InstanceList{}

if err := r.List(context.Background(), list, client.InNamespace(nsName)); err != nil {
if err := r.List(ctx, list, client.InNamespace(nsName)); err != nil {
return true, err
}

Expand Down
4 changes: 2 additions & 2 deletions operators/pkg/tenant-controller/tenant_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ var _ = Describe("Tenant controller", func() {

})

func checkTnPVBound(ctx context.Context, tnName, nsName string, timeout, interval time.Duration, serverName, rookCephNamespace, path string) {
func checkTnPVBound(ctx context.Context, tnName string, timeout, interval time.Duration, serverName, rookCephNamespace, path string) {
var pvc v1.PersistentVolumeClaim
doesEventuallyExists(ctx, types.NamespacedName{Name: myDrivePVCName(tnName), Namespace: testMyDrivePVCsNamespace}, &pvc, BeTrue(), timeout, interval)

Expand Down Expand Up @@ -432,7 +432,7 @@ func checkTnClusterResourceCreation(ctx context.Context, tnName, nsName string,
Expect(createdNetPolAllow.Spec.Ingress[0].From[0].NamespaceSelector.MatchLabels["crownlabs.polito.it/allow-instance-access"]).Should(Equal("true"))

By("By checking that the mydrive-info secret of the tenant has been created")
checkTnPVBound(ctx, tnName, nsName, timeout, interval, serverName, rookCephNamespace, path)
checkTnPVBound(ctx, tnName, timeout, interval, serverName, rookCephNamespace, path)

By("By checking that the mydrive-info secret of the tenant has been created")
NFSSecretLookupKey := types.NamespacedName{Name: NFSSecretName, Namespace: nsName}
Expand Down

0 comments on commit 53a922e

Please sign in to comment.