Skip to content

Commit

Permalink
feat: initialize project
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Oct 15, 2024
1 parent b497516 commit 3f42d79
Show file tree
Hide file tree
Showing 15 changed files with 676 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
28 changes: 28 additions & 0 deletions .github/workflows/check-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Size

on:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]

permissions:
contents: read

jobs:
check_size:
name: Check Size
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
with:
fetch-depth: 1

- name: Check large files
uses: actionsdesk/lfs-warning@e5f9a4c21f4bee104db7c0f23954dde59e5df909
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filesizelimit: "1048576"
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
pull_request:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
schedule:
- cron: '0 4 * * *'

permissions:
contents: read

jobs:
test:
name: Test
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
with:
submodules: recursive

- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: go.mod

- name: Run Unit tests
run: |-
echo running unit tests
42 changes: 42 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CodeQL Analysis

on:
push:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
pull_request:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
schedule:
- cron: '0 4 * * *'

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
security-events: write

strategy:
fail-fast: false
matrix:
language: [go]

steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938

- name: Initialize CodeQL
uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@c36620d31ac7c881962c3d9dd939c40ec9434f2b

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938

- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: go.mod
cache: false

- name: Golangci lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86
with:
version: v1.54
args: --verbose
23 changes: 23 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 The CNAI Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import "github.com/CloudNativeAI/modctl/cmd/modctl"

func main() {
modctl.Execute()
}
55 changes: 55 additions & 0 deletions cmd/modctl/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 The CNAI Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modctl

import (
"context"
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// listCmd represents the modctl command for list.
var listCmd = &cobra.Command{
Use: "list [flags]",
Short: "A command line tool for modctl list",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
RunE: func(cmd *cobra.Command, args []string) error {
logrus.Infof("running list")
return runList(context.Background())
},
}

// init initializes list command.
func init() {
flags := listCmd.Flags()

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache list flags to viper: %w", err))
}
}

// runList runs the list modctl.
func runList(ctx context.Context) error {
// TODO: Add list modctl logic here.
return nil
}
55 changes: 55 additions & 0 deletions cmd/modctl/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 The CNAI Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modctl

import (
"context"
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// loginCmd represents the modctl command for login.
var loginCmd = &cobra.Command{
Use: "login [flags]",
Short: "A command line tool for modctl login",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelogin: cobra.FParseErrWhitelogin{UnknownFlags: true},

Check failure on line 35 in cmd/modctl/login.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field FParseErrWhitelogin in struct literal of type cobra.Command

Check failure on line 35 in cmd/modctl/login.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: cobra.FParseErrWhitelogin
RunE: func(cmd *cobra.Command, args []string) error {
logrus.Infof("running login")
return runLogin(context.Background())
},
}

// init initializes login command.
func init() {
flags := loginCmd.Flags()

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache login flags to viper: %w", err))
}
}

// runLogin runs the login modctl.
func runLogin(ctx context.Context) error {
// TODO: Add login modctl logic here.
return nil
}
55 changes: 55 additions & 0 deletions cmd/modctl/logout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 The CNAI Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modctl

import (
"context"
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// logoutCmd represents the modctl command for logout.
var logoutCmd = &cobra.Command{
Use: "logout [flags]",
Short: "A command line tool for modctl logout",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelogout: cobra.FParseErrWhitelogout{UnknownFlags: true},

Check failure on line 35 in cmd/modctl/logout.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field FParseErrWhitelogout in struct literal of type cobra.Command

Check failure on line 35 in cmd/modctl/logout.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: cobra.FParseErrWhitelogout
RunE: func(cmd *cobra.Command, args []string) error {
logrus.Infof("running logout")
return runLogout(context.Background())
},
}

// init initializes logout command.
func init() {
flags := logoutCmd.Flags()

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache logout flags to viper: %w", err))
}
}

// runLogout runs the logout modctl.
func runLogout(ctx context.Context) error {
// TODO: Add logout modctl logic here.
return nil
}
55 changes: 55 additions & 0 deletions cmd/modctl/pull.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 The CNAI Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modctl

import (
"context"
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// pullCmd represents the modctl command for pull.
var pullCmd = &cobra.Command{
Use: "pull [flags]",
Short: "A command line tool for modctl pull",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitepull: cobra.FParseErrWhitepull{UnknownFlags: true},

Check failure on line 35 in cmd/modctl/pull.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field FParseErrWhitepull in struct literal of type cobra.Command

Check failure on line 35 in cmd/modctl/pull.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: cobra.FParseErrWhitepull
RunE: func(cmd *cobra.Command, args []string) error {
logrus.Infof("running pull")
return runPull(context.Background())
},
}

// init initializes pull command.
func init() {
flags := pullCmd.Flags()

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache pull flags to viper: %w", err))
}
}

// runPull runs the pull modctl.
func runPull(ctx context.Context) error {
// TODO: Add pull modctl logic here.
return nil
}
Loading

0 comments on commit 3f42d79

Please sign in to comment.