Skip to content

Commit

Permalink
Merge pull request #928 from CircleCI-Public/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
JulesFaucherre authored May 4, 2023
2 parents cc8c4de + d97db20 commit 7b38e08
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- id: config-validate
name: Validate CircleCI config
entry: circleci config validate --skip-update-check
language: golang
files: .circleci/config.yml
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM cimg/go:1.20

LABEL maintainer="Developer Experience Team <[email protected]>"

ENV CIRCLECI_CLI_SKIP_UPDATE_CHECK true

COPY ./dist/circleci-cli_linux_amd64/circleci /usr/local/bin
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ CircleCI host has been set.
Setup complete. Your configuration has been saved.
```

If you are using this tool on `circleci.com`, accept the provided default `CircleCI Host`.

If you are using this tool on `circleci.com`. accept the provided default `CircleCI Host`.

Server users will have to change the default value to your custom address (i.e. `circleci.my-org.com`).
Server users will have to change the default value to your custom address (e.g., `circleci.my-org.com`).

**Note**: Server does not yet support config processing and orbs, you will only be able to use `circleci local execute` (previously `circleci build`) for now.

Expand Down Expand Up @@ -153,7 +152,7 @@ The following commands are affected:

## Platforms, Deployment and Package Managers

The tool is deployed through a number of channels. The primary release channel is through [GitHub Releases](https://github.com/CircleCI-Public/circleci-cli/releases). Green builds on the `main` branch will publish a new GitHub release. These releases contain binaries for macOS, Linux and Windows. These releases are published from (CircleCI)[https://app.circleci.com/pipelines/github/CircleCI-Public/circleci-cli] using (GoReleaser)[https://goreleaser.com/].
The tool is deployed through a number of channels. The primary release channel is through [GitHub Releases](https://github.com/CircleCI-Public/circleci-cli/releases). Green builds on the `main` branch will publish a new GitHub release. These releases contain binaries for macOS, Linux and Windows. These releases are published from (CircleCI)[https://app.circleci.com/pipelines/github/CircleCI-Public/circleci-cli] using [GoReleaser](https://goreleaser.com/).

### Homebrew

Expand Down
1 change: 1 addition & 0 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ type OrbSchema struct {

type ExampleUsageSchema struct {
Version string `yaml:"version,omitempty"`
Setup bool `yaml:"setup,omitempty"`
Orbs interface{} `yaml:"orbs,omitempty"`
Jobs interface{} `yaml:"jobs,omitempty"`
Workflows interface{} `yaml:"workflows"`
Expand Down
31 changes: 27 additions & 4 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,20 @@ Windows Server 2010
- run:
name: Say hello
command: <<include(scripts/script.sh)>>
examples:
example:
description: |
An example of how to use the orb.
usage:
version: 2.1
orbs:
orb-name: company/[email protected]
setup: true
workflows:
create-pipeline:
jobs:
orb-name: create-pipeline-x
`))
script = clitest.OpenTmpFile(tempSettings.Home, filepath.Join("scripts", "script.sh"))
script.Write([]byte(`echo Hello, world!`))
Expand All @@ -3330,17 +3344,26 @@ Windows Server 2010
It("Includes a script in the packed Orb file", func() {
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())

Eventually(session.Out).Should(gbytes.Say(`commands:
orb:
steps:
Eventually(session.Out).Should(gbytes.Say(`steps:
- run:
command: echo Hello, world!
name: Say hello
`))
Eventually(session).Should(gexec.Exit(0))
})

It("Includes the setup key when an orb example uses a dynamic pipeline", func() {
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say(`orbs:
orb-name: company/[email protected]
setup: true
version: 2.1
workflows:
`))
Eventually(session).Should(gexec.Exit(0))
})

})

Describe("Orb diff", func() {
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *ConfigCompiler) ConfigQuery(
return legacyResponse, nil
}
if originalErr != nil {
return nil, fmt.Errorf("config compilation request returned an error: %w", err)
return nil, fmt.Errorf("config compilation request returned an error: %w", originalErr)
}

if statusCode != 200 {
Expand Down
11 changes: 7 additions & 4 deletions local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
var picardRepo = "circleci/picard"

const DefaultConfigPath = ".circleci/config.yml"
const DefaultDockerSocketPath = "/var/run/docker.sock"

func Execute(flags *pflag.FlagSet, cfg *settings.Config, args []string) error {
var err error
Expand Down Expand Up @@ -80,7 +81,8 @@ func Execute(flags *pflag.FlagSet, cfg *settings.Config, args []string) error {
}

job := args[0]
arguments := generateDockerCommand(processedConfigPath, image, pwd, job, processedArgs...)
dockerSocketPath, _ := flags.GetString("docker-socket-path")
arguments := generateDockerCommand(processedConfigPath, image, pwd, job, dockerSocketPath, processedArgs...)

if cfg.Debug {
_, err = fmt.Fprintf(os.Stderr, "Starting docker with args: %s", arguments)
Expand Down Expand Up @@ -114,6 +116,7 @@ func AddFlagsForDocumentation(flags *pflag.FlagSet) {
flags.String("branch", "", "Git branch")
flags.String("repo-url", "", "Git Url")
flags.StringArrayP("env", "e", nil, "Set environment variables, e.g. `-e VAR=VAL`")
flags.String("docker-socket-path", DefaultDockerSocketPath, "Path to the host's docker socket")
}

// Given the full set of flags that were passed to this command, return the path
Expand All @@ -131,7 +134,7 @@ func buildAgentArguments(flags *pflag.FlagSet) ([]string, string) {

// build a list of all supplied flags, that we will pass on to build-agent
flags.Visit(func(flag *pflag.Flag) {
if flag.Name != "build-agent-version" && flag.Name != "org-slug" && flag.Name != "config" && flag.Name != "debug" && flag.Name != "org-id" {
if flag.Name != "build-agent-version" && flag.Name != "org-slug" && flag.Name != "config" && flag.Name != "debug" && flag.Name != "org-id" && flag.Name != "docker-socket-path" {
result = append(result, unparseFlag(flags, flag)...)
}
})
Expand Down Expand Up @@ -272,10 +275,10 @@ func writeStringToTempFile(data string) (string, error) {
return f.Name(), nil
}

func generateDockerCommand(configPath, image, pwd string, job string, arguments ...string) []string {
func generateDockerCommand(configPath, image, pwd string, job string, dockerSocketPath string, arguments ...string) []string {
const configPathInsideContainer = "/tmp/local_build_config.yml"
core := []string{"docker", "run", "--interactive", "--tty", "--rm",
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
"--volume", fmt.Sprintf("%s:/var/run/docker.sock", dockerSocketPath),
"--volume", fmt.Sprintf("%s:%s", configPath, configPathInsideContainer),
"--volume", fmt.Sprintf("%s:%s", pwd, pwd),
"--volume", fmt.Sprintf("%s:/root/.circleci", settings.SettingsPath()),
Expand Down
2 changes: 1 addition & 1 deletion local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _ = Describe("build", func() {
It("can generate a command line", func() {
home, err := os.UserHomeDir()
Expect(err).NotTo(HaveOccurred())
Expect(generateDockerCommand("/config/path", "docker-image-name", "/current/directory", "build", "extra-1", "extra-2")).To(ConsistOf(
Expect(generateDockerCommand("/config/path", "docker-image-name", "/current/directory", "build", "/var/run/docker.sock", "extra-1", "extra-2")).To(ConsistOf(
"docker",
"run",
"--interactive",
Expand Down

0 comments on commit 7b38e08

Please sign in to comment.