From f53b67fa8166650f41d3282446d110f4e299df9e Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Sat, 10 Aug 2024 16:01:31 +0200 Subject: [PATCH 1/2] Chore: replace woodpecker with forgejo actions --- .../workflows/docker-build-push-master.yml | 21 +++++++ .forgejo/workflows/docker-build-push-tag.yml | 21 +++++++ .forgejo/workflows/docker-build.yml | 16 ++++++ .forgejo/workflows/go-test.yml | 17 ++++++ .woodpecker/deploy.yml | 57 ------------------- .woodpecker/test.yml | 13 ----- README.md | 3 +- 7 files changed, 76 insertions(+), 72 deletions(-) create mode 100644 .forgejo/workflows/docker-build-push-master.yml create mode 100644 .forgejo/workflows/docker-build-push-tag.yml create mode 100644 .forgejo/workflows/docker-build.yml create mode 100644 .forgejo/workflows/go-test.yml delete mode 100644 .woodpecker/deploy.yml delete mode 100644 .woodpecker/test.yml diff --git a/.forgejo/workflows/docker-build-push-master.yml b/.forgejo/workflows/docker-build-push-master.yml new file mode 100644 index 0000000..d5a1e37 --- /dev/null +++ b/.forgejo/workflows/docker-build-push-master.yml @@ -0,0 +1,21 @@ +on: + push: + branches: + - "main" +jobs: + docker-build-push: + runs-on: cth-ubuntu-latest + steps: + - name: set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: login to repository + uses: docker/login-action@v3 + with: + registry: git.faercol.me + username: ${{ secrets.DOCKER_LOGIN }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: build and push image + uses: docker/build-push-action@v6 + with: + push: true + tags: git.faercol.me/polyculeconnect/polyculeconnect:latest diff --git a/.forgejo/workflows/docker-build-push-tag.yml b/.forgejo/workflows/docker-build-push-tag.yml new file mode 100644 index 0000000..fafa715 --- /dev/null +++ b/.forgejo/workflows/docker-build-push-tag.yml @@ -0,0 +1,21 @@ +on: + push: + tags: + - "**" +jobs: + docker-build-push: + runs-on: cth-ubuntu-latest + steps: + - name: set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: login to repository + uses: docker/login-action@v3 + with: + registry: git.faercol.me + username: ${{ secrets.DOCKER_LOGIN }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: build and push image + uses: docker/build-push-action@v6 + with: + push: true + tags: git.faercol.me/polyculeconnect/polyculeconnect:${{ gitea.ref_name }} diff --git a/.forgejo/workflows/docker-build.yml b/.forgejo/workflows/docker-build.yml new file mode 100644 index 0000000..51cd8d9 --- /dev/null +++ b/.forgejo/workflows/docker-build.yml @@ -0,0 +1,16 @@ +on: + push: + branches: + - "**" + - "!main" +jobs: + docker-build-only: + runs-on: cth-ubuntu-latest + steps: + - name: set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: build image (build only) + uses: docker/build-push-action@v6 + with: + push: false + tags: git.faercol.me/polyculeconnect/polyculeconnect diff --git a/.forgejo/workflows/go-test.yml b/.forgejo/workflows/go-test.yml new file mode 100644 index 0000000..7bb900a --- /dev/null +++ b/.forgejo/workflows/go-test.yml @@ -0,0 +1,17 @@ +on: + push: + branches: + - "**" +jobs: + go-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 1.22 + - name: Run unit tests + run: make -C polyculeconnect test + - name: Build go package + run: make -C polyculeconnect build diff --git a/.woodpecker/deploy.yml b/.woodpecker/deploy.yml deleted file mode 100644 index 36f5034..0000000 --- a/.woodpecker/deploy.yml +++ /dev/null @@ -1,57 +0,0 @@ -steps: - docker-build-only: - image: woodpeckerci/plugin-docker-buildx - privileged: true - settings: - repo: git.faercol.me/polyculeconnect/polyculeconnect - tags: latest - dry_run: true - platforms: - - linux/amd64 - # - linux/arm64 - when: - - event: pull_request - - event: push - branch: - exclude: [main] - - docker-build-push: - image: woodpeckerci/plugin-docker-buildx - privileged: true - settings: - repo: git.faercol.me/polyculeconnect/polyculeconnect - registry: git.faercol.me - tags: latest - username: - from_secret: git_username - password: - from_secret: git_password - platforms: - - linux/amd64 - # - linux/arm64 - when: - - event: push - branch: main - - docker-push-tag: - image: woodpeckerci/plugin-docker-buildx - privileged: true - settings: - registry: git.faercol.me - repo: git.faercol.me/polyculeconnect/polyculeconnect - auto_tag: true - platforms: - - linux/amd64 - # - linux/arm64 - username: - from_secret: git_username - password: - from_secret: git_password - when: - - event: tag - -depends_on: - - test - -when: - event: [push, tag] diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml deleted file mode 100644 index be910ab..0000000 --- a/.woodpecker/test.yml +++ /dev/null @@ -1,13 +0,0 @@ -steps: - go-test: - image: golang - commands: - - make -C polyculeconnect test - - go-build: - image: golang - commands: - - make -C polyculeconnect build - -when: - event: [push, tag] diff --git a/README.md b/README.md index 71832ee..db6edf6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # PolyculeConnect -[![status-badge](https://ci-polycule-connect.chapoline.me/api/badges/1/status.svg)](https://ci-polycule-connect.chapoline.me/repos/1) -[![status-badge](https://ci-server.internal.faercol.me/api/badges/2/status.svg)](https://ci-server.internal.faercol.me/repos/2) +[![status-badge](https://git.faercol.me/PolyculeConnect/polycule-connect/badges/workflows/go-test.yml/badge.svg?branch=main)](https://ci-polycule-connect.chapoline.me/repos/1) ![Project logo](./polyculeconnect/static/img/logo-text.png) -- 2.45.2 From 344589829b69a204368bbb6c90ec4a10fc1b1944 Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Sat, 10 Aug 2024 16:27:49 +0200 Subject: [PATCH 2/2] Chore: remove generated cobra comments and improve help messages --- polyculeconnect/cmd/app/remove.go | 6 ++---- polyculeconnect/cmd/app/show.go | 4 ++-- polyculeconnect/cmd/backend/backend.go | 9 ++------- polyculeconnect/cmd/backend/remove.go | 6 ++---- polyculeconnect/cmd/backend/show.go | 4 ++-- polyculeconnect/cmd/db/connect.go | 10 ---------- polyculeconnect/cmd/db/db.go | 10 ---------- polyculeconnect/cmd/db/destroy.go | 10 ---------- polyculeconnect/cmd/root.go | 14 -------------- polyculeconnect/cmd/serve/serve.go | 10 ---------- 10 files changed, 10 insertions(+), 73 deletions(-) diff --git a/polyculeconnect/cmd/app/remove.go b/polyculeconnect/cmd/app/remove.go index 252f4be..3d29ed6 100644 --- a/polyculeconnect/cmd/app/remove.go +++ b/polyculeconnect/cmd/app/remove.go @@ -13,10 +13,8 @@ import ( var appRemoveCmd = &cobra.Command{ Use: "remove ", Short: "Remove an app", - Long: `Remove the app with the given ID from the database. - -If the app is not found in the database, no error is returned`, - Args: cobra.ExactArgs(1), + Long: `Remove the app with the given ID from the database.`, + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { removeApp(args[0]) }, diff --git a/polyculeconnect/cmd/app/show.go b/polyculeconnect/cmd/app/show.go index 4b58984..3c1e79e 100644 --- a/polyculeconnect/cmd/app/show.go +++ b/polyculeconnect/cmd/app/show.go @@ -15,8 +15,8 @@ var appShowCmd = &cobra.Command{ Short: "Display installed apps", Long: `Display the configuration for the apps. -Pass the commands without arguments to display the list of currently installed apps -Pass the optional 'id' argument to display the configuration for this specific app`, +Optional parameters: +- app-id: id of the application to display. If empty, display the list of available apps instead`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { s := utils.InitStorage(utils.InitConfig("")) diff --git a/polyculeconnect/cmd/backend/backend.go b/polyculeconnect/cmd/backend/backend.go index a45fb6c..b971f35 100644 --- a/polyculeconnect/cmd/backend/backend.go +++ b/polyculeconnect/cmd/backend/backend.go @@ -9,13 +9,8 @@ import ( var backendCmd = &cobra.Command{ Use: "backend", - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, + Short: "Handle authentication backends", + Long: `Add, Remove or Show currently installed authentication backends`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("backend called") }, diff --git a/polyculeconnect/cmd/backend/remove.go b/polyculeconnect/cmd/backend/remove.go index de6fe0e..de52874 100644 --- a/polyculeconnect/cmd/backend/remove.go +++ b/polyculeconnect/cmd/backend/remove.go @@ -13,10 +13,8 @@ import ( var backendRemoveCmd = &cobra.Command{ Use: "remove ", Short: "Remove a backend", - Long: `Remove the backend with the given ID from the database. - -If the backend is not found in the database, no error is returned`, - Args: cobra.ExactArgs(1), + Long: `Remove the backend with the given ID from the database.`, + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { removeBackend(args[0]) }, diff --git a/polyculeconnect/cmd/backend/show.go b/polyculeconnect/cmd/backend/show.go index e1a6ce6..1fc8253 100644 --- a/polyculeconnect/cmd/backend/show.go +++ b/polyculeconnect/cmd/backend/show.go @@ -15,8 +15,8 @@ var backendShowCmd = &cobra.Command{ Short: "Display installed backends", Long: `Display the configuration for the backends. -Pass the commands without arguments to display the list of currently installed backends -Pass the optional 'id' argument to display the configuration for this specific backend`, +Optional parameters: +- app-id: id of the backend to display. If empty, display the list of available backends instead`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { s := utils.InitStorage(utils.InitConfig("")) diff --git a/polyculeconnect/cmd/db/connect.go b/polyculeconnect/cmd/db/connect.go index 6960bd4..bdacdbe 100644 --- a/polyculeconnect/cmd/db/connect.go +++ b/polyculeconnect/cmd/db/connect.go @@ -52,14 +52,4 @@ func connectToDB(conf *config.AppConfig) error { func init() { dbCmd.AddCommand(connectCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // dbCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // dbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } diff --git a/polyculeconnect/cmd/db/db.go b/polyculeconnect/cmd/db/db.go index 0df72fc..c95f196 100644 --- a/polyculeconnect/cmd/db/db.go +++ b/polyculeconnect/cmd/db/db.go @@ -14,14 +14,4 @@ var dbCmd = &cobra.Command{ func init() { cmd.RootCmd.AddCommand(dbCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // dbCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // dbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } diff --git a/polyculeconnect/cmd/db/destroy.go b/polyculeconnect/cmd/db/destroy.go index 1fef2e9..77f7574 100644 --- a/polyculeconnect/cmd/db/destroy.go +++ b/polyculeconnect/cmd/db/destroy.go @@ -47,14 +47,4 @@ func deleteDB(conf *config.AppConfig) error { func init() { dbCmd.AddCommand(destroyCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // dbCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // dbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } diff --git a/polyculeconnect/cmd/root.go b/polyculeconnect/cmd/root.go index 3e792a3..9fae3d2 100644 --- a/polyculeconnect/cmd/root.go +++ b/polyculeconnect/cmd/root.go @@ -12,9 +12,6 @@ var RootCmd = &cobra.Command{ Short: "You're in their DMs, I'm in their SSO", Long: `PolyculeConnect is a SSO OpenIDConnect provider which allows multiple authentication backends, and enables authentication federation among several infrastructures.`, - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, } // Execute adds all child commands to the root command and sets flags appropriately. @@ -27,16 +24,5 @@ func Execute() { } func init() { - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.polyculeconnect.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - - // Disable the default `completion` command to generate the autocompletion files RootCmd.Root().CompletionOptions.DisableDefaultCmd = true } diff --git a/polyculeconnect/cmd/serve/serve.go b/polyculeconnect/cmd/serve/serve.go index 9022dce..1c4a98f 100644 --- a/polyculeconnect/cmd/serve/serve.go +++ b/polyculeconnect/cmd/serve/serve.go @@ -113,15 +113,5 @@ func serve() { func init() { cmd.RootCmd.AddCommand(serveCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // serveCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // serveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") serveCmd.Flags().StringVarP(&configPath, "config", "c", "config.json", "Path to the JSON configuration file") } -- 2.45.2