Skip to content

Commit

Permalink
fix(app): add github action for linting and formatting [EE-2344] (#6356)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiptus authored Jan 17, 2022
1 parent 34cc8ea commit 1b1a50d
Show file tree
Hide file tree
Showing 313 changed files with 2,633 additions and 3,821 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ overrides:
'jest/globals': true
rules:
'react/jsx-no-constructed-context-values': off
- files:
- app/**/*.stories.*
rules:
'no-alert': off
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# prettier
cf5056d9c03b62d91a25c3b9127caac838695f98

# prettier v2 (put here after fix/EE-2344/fix-eslint-issues is merged)
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
push:
branches:
- master
- develop
- release/*
pull_request:
branches:
- master
- develop
- release/*

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12

# ESLint and Prettier must be in `package.json`
- name: Install Node.js dependencies
run: yarn

- name: Run linters
uses: wearerequired/lint-action@v1
with:
eslint: true
eslint_extensions: ts,tsx,js,jsx
prettier: true
prettier_dir: app/
gofmt: true
gofmt_dir: api/
11 changes: 11 additions & 0 deletions .github/workflows/test-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Test Frontend
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Run tests
run: yarn test:client
11 changes: 3 additions & 8 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@
"htmlWhitespaceSensitivity": "strict",
"overrides": [
{
"files": [
"*.html"
],
"files": ["*.html"],
"options": {
"parser": "angular"
}
},
{
"files": [
"*.{j,t}sx",
"*.ts"
],
"files": ["*.{j,t}sx", "*.ts"],
"options": {
"printWidth": 80
}
}
]
}
}
3 changes: 2 additions & 1 deletion .vscode.example/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast", "-E", "exportloopref"]
"go.lintFlags": ["--fast", "-E", "exportloopref"],
"gitlens.advanced.blame.customArguments": ["–ignore-revs-file", ".git-blame-ignore-revs"]
}
4 changes: 2 additions & 2 deletions api/datastore/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func (store *Store) Init() error {
AutoCreateUsers: true,
TLSConfig: portainer.TLSConfiguration{},
SearchSettings: []portainer.LDAPSearchSettings{
portainer.LDAPSearchSettings{},
{},
},
GroupSearchSettings: []portainer.LDAPGroupSearchSettings{
portainer.LDAPGroupSearchSettings{},
{},
},
},
OAuthSettings: portainer.OAuthSettings{},
Expand Down
2 changes: 1 addition & 1 deletion api/docker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func createEdgeClient(endpoint *portainer.Endpoint, signatureService portainer.D
if err != nil {
return nil, err
}

endpointURL := fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port)

return client.NewClientWithOpts(
Expand Down
2 changes: 1 addition & 1 deletion api/exec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s StringSet) List() []string {
list := make([]string, s.Len())

i := 0
for k, _ := range s {
for k := range s {
list[i] = k
i++
}
Expand Down
2 changes: 1 addition & 1 deletion api/http/handler/endpointproxy/proxy_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
portainer "github.com/portainer/portainer/api"
"strconv"
"strings"
portainer "github.com/portainer/portainer/api"

"net/http"
)
Expand Down
2 changes: 1 addition & 1 deletion api/http/handler/registries/registry_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type registryConfigurePayload struct {
// Password used to authenticate against this registry. required when Authentication is true
Password string `example:"registry_password"`
// ECR region
Region string
Region string
// Use TLS
TLS bool `example:"true"`
// Skip the verification of the server TLS certificate
Expand Down
6 changes: 3 additions & 3 deletions api/http/handler/registries/registry_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type registryUpdatePayload struct {
// Username used to authenticate against this registry. Required when Authentication is true
Username *string `example:"registry_user"`
// Password used to authenticate against this registry. required when Authentication is true
Password *string `example:"registry_password"`
Password *string `example:"registry_password"`
// Quay data
Quay *portainer.QuayRegistryData
Quay *portainer.QuayRegistryData
// Registry access control
RegistryAccesses *portainer.RegistryAccesses `json:",omitempty"`
// ECR data
Ecr *portainer.EcrData `json:",omitempty"`
Ecr *portainer.EcrData `json:",omitempty"`
}

func (payload *registryUpdatePayload) Validate(r *http.Request) error {
Expand Down
2 changes: 1 addition & 1 deletion api/http/handler/webhooks/webhook_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type webhookCreatePayload struct {
ResourceID string
EndpointID int
RegistryID portainer.RegistryID
RegistryID portainer.RegistryID
WebhookType int
}

Expand Down
4 changes: 2 additions & 2 deletions api/http/handler/webhooks/webhook_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func (handler *Handler) executeServiceWebhook(
}

service.Spec.TaskTemplate.ForceUpdate++

var imageName = strings.Split(service.Spec.TaskTemplate.ContainerSpec.Image, "@sha")[0]

if imageTag != "" {
var tagIndex = strings.LastIndex(imageName, ":")
if tagIndex == -1 {
tagIndex = len(imageName)
tagIndex = len(imageName)
}
service.Spec.TaskTemplate.ContainerSpec.Image = imageName[:tagIndex] + ":" + imageTag
} else {
Expand Down
2 changes: 1 addition & 1 deletion api/http/proxy/factory/kubernetes/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func (transport *baseTransport) proxyDeploymentsRequest(request *http.Request, n
default:
return transport.executeKubernetesRequest(request)
}
}
}
2 changes: 1 addition & 1 deletion api/http/proxy/factory/kubernetes/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func (transport *baseTransport) proxyPodsRequest(request *http.Request, namespac
default:
return transport.executeKubernetesRequest(request)
}
}
}
2 changes: 1 addition & 1 deletion api/http/proxy/factory/kubernetes/refresh_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ func (transport *baseTransport) refreshRegistry(request *http.Request, namespace
err = registryutils.RefreshEcrSecret(cli, transport.endpoint, transport.dataStore, namespace)

return
}
}
2 changes: 1 addition & 1 deletion api/internal/endpointutils/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ func Test_FilterByExcludeIDs(t *testing.T) {
tt.asserts(t, output)
})
}
}
}
2 changes: 1 addition & 1 deletion api/kubernetes/cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (factory *ClientFactory) GetInstanceID() (instanceID string) {
}

// Remove the cached kube client so a new one can be created
func (factory *ClientFactory) RemoveKubeClient(endpointID portainer.EndpointID) {
func (factory *ClientFactory) RemoveKubeClient(endpointID portainer.EndpointID) {
factory.endpointClients.Remove(strconv.Itoa(int(endpointID)))
}

Expand Down
4 changes: 2 additions & 2 deletions api/kubernetes/cli/registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

const (
secretDockerConfigKey = ".dockerconfigjson"
labelRegistryType = "io.portainer.kubernetes.registry.type"
annotationRegistryID = "portainer.io/registry.id"
labelRegistryType = "io.portainer.kubernetes.registry.type"
annotationRegistryID = "portainer.io/registry.id"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion app/agent/components/file-uploader/fileUploader.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<button type="button" ngf-select="$ctrl.onFileSelected($file)" class="btn ng-scope" button-spinner="$ctrl.state.uploadInProgress">
<i style="margin: 0;" class="fa fa-upload" ng-if="!$ctrl.state.uploadInProgress"></i>
<i style="margin: 0" class="fa fa-upload" ng-if="!$ctrl.state.uploadInProgress"></i>
</button>
4 changes: 1 addition & 3 deletions app/agent/components/files-datatable/filesDatatable.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
<i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'ModTime' && $ctrl.state.reverseOrder"></i>
</a>
</th>
<th>
Actions
</th>
<th> Actions </th>
</tr>
</thead>
<tbody>
Expand Down
34 changes: 17 additions & 17 deletions app/assets/ico/manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "Portainer",
"icons": [
{
"src": "ico/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "ico/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
"name": "Portainer",
"icons": [
{
"src": "ico/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "ico/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div>
<div class="col-sm-12 form-section-title">
Azure configuration
</div>
<div class="col-sm-12 form-section-title"> Azure configuration </div>
<!-- applicationId-input -->
<div class="form-group">
<label for="azure_credential_appid" class="col-sm-3 col-lg-2 control-label text-left">Application ID</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<rd-widget>
<rd-widget-body classes="no-padding">
<div class="toolBar">
<div class="toolBarTitle"> <i class="fa" ng-class="$ctrl.titleIcon" aria-hidden="true" style="margin-right: 2px;"></i> {{ $ctrl.titleText }} </div>
<div class="toolBarTitle"> <i class="fa" ng-class="$ctrl.titleIcon" aria-hidden="true" style="margin-right: 2px"></i> {{ $ctrl.titleText }} </div>
</div>
<div class="actionBar">
<button type="button" class="btn btn-sm btn-danger" ng-disabled="$ctrl.state.selectedItemCount === 0" ng-click="$ctrl.removeAction($ctrl.state.selectedItems)">
Expand Down Expand Up @@ -46,9 +46,7 @@
<i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Location' && $ctrl.state.reverseOrder"></i>
</a>
</th>
<th>
Published Ports
</th>
<th> Published Ports </th>
<th>
<a ng-click="$ctrl.changeOrderBy('ResourceControl.Ownership')">
Ownership
Expand Down Expand Up @@ -98,9 +96,7 @@
<div class="paginationControls">
<form class="form-inline">
<span class="limitSelector">
<span style="margin-right: 5px;">
Items per page
</span>
<span style="margin-right: 5px"> Items per page </span>
<select class="form-control" ng-model="$ctrl.state.paginatedItemLimit" ng-change="$ctrl.changePaginationLimit()" data-cy="component-paginationSelect">
<option value="0">All</option>
<option value="10">10</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<rd-widget>
<rd-widget-body>
<div class="form-horizontal" autocomplete="off">
<div class="col-sm-12 form-section-title">
Azure settings
</div>
<div class="col-sm-12 form-section-title"> Azure settings </div>
<!-- subscription-input -->
<div class="form-group">
<label for="azure_subscription" class="col-sm-2 control-label text-left">Subscription</label>
Expand All @@ -35,9 +33,7 @@
</div>
</div>
<!-- !location-input -->
<div class="col-sm-12 form-section-title">
Container configuration
</div>
<div class="col-sm-12 form-section-title"> Container configuration </div>
<!-- name-input -->
<div class="form-group">
<label for="container_name" class="col-sm-2 control-label text-left">Name</label>
Expand Down Expand Up @@ -68,15 +64,15 @@
<label class="control-label text-left">Port mapping</label>
</div>
<!-- port-mapping-input-list -->
<div class="col-sm-12 form-inline" style="margin-top: 10px;">
<div ng-repeat="binding in $ctrl.container.Ports" style="margin-top: 2px;">
<div class="col-sm-12 form-inline" style="margin-top: 10px">
<div ng-repeat="binding in $ctrl.container.Ports" style="margin-top: 2px">
<!-- host-port -->
<div class="input-group col-sm-4 input-group-sm">
<span class="input-group-addon">host</span>
<input type="text" class="form-control" ng-model="binding.host" placeholder="e.g. 80" disabled />
</div>
<!-- !host-port -->
<span style="margin: 0 10px 0 10px;">
<span style="margin: 0 10px 0 10px">
<i class="fa fa-long-arrow-alt-right" aria-hidden="true"></i>
</span>
<!-- container-port -->
Expand All @@ -100,17 +96,13 @@
<!-- !port-mapping -->
<!-- public-ip -->
<div class="form-group" ng-if="$ctrl.container.AllocatePublicIP">
<label for="public_ip" class="col-sm-2 control-label text-left">
Public IP
</label>
<label for="public_ip" class="col-sm-2 control-label text-left"> Public IP </label>
<div class="col-sm-10">
<input type="text" class="form-control" ng-model="$ctrl.container.IPAddress" disabled />
</div>
</div>
<!-- public-ip -->
<div class="col-sm-12 form-section-title">
Container resources
</div>
<div class="col-sm-12 form-section-title"> Container resources </div>
<!-- cpu-input -->
<div class="form-group">
<label for="container_cpu" class="col-sm-2 control-label text-left">CPU</label>
Expand Down
Loading

0 comments on commit 1b1a50d

Please sign in to comment.