Skip to content

Commit

Permalink
Merge branch 'master' into support-issue-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkalderimis authored May 11, 2020
2 parents df7e662 + 0d9ac83 commit 8e68f5f
Show file tree
Hide file tree
Showing 84 changed files with 943 additions and 346 deletions.
12 changes: 12 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 1

test_patterns = [
"*_test.go"
]

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_path = "github.com/zaquestion/lab"
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: zaquestion
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ scoop:
email: goreleaser@carlosbecker.com
homepage: "https://github.com/zaquestion/lab"
description: "Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab"
license: Unlicense
license: CC0
builds:
- goos:
- linux
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
- linux

go:
- 1.11.x
- 1.13.x

# use containers which run faster and have cache
sudo: false
Expand Down
9 changes: 0 additions & 9 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lab will look for hub and uses that as your git binary when available so you don
$ lab version
git version 2.11.0
hub version 2.3.0-pre9
lab version 0.16.0
lab version 0.17.2
```

# Inspiration
Expand All @@ -42,12 +42,20 @@ scoop bucket add zaquestion https://github.com/zaquestion/scoop-bucket.git
scoop install lab
```

### Alpine
```
apk add lab
```

### Bash

Installs lab into `/usr/local/bin/`
```
curl -s https://raw.githubusercontent.com/zaquestion/lab/master/install.sh | bash
curl -s https://raw.githubusercontent.com/zaquestion/lab/master/install.sh | sudo bash
```
NOTE: Please take care when executing scripts in this fashion. Make sure you
trust the developer providing the script and consider peaking at the install
script itself (ours is pretty simply ;)

### PreBuilt Binaries

Expand All @@ -56,7 +64,7 @@ Head to the [releases](https://github.com/zaquestion/lab/releases) page and down
### Source

Required
* [Go 1.11+](https://golang.org/doc/install)
* [Go 1.12+](https://golang.org/doc/install)

```
git clone git@github.com:zaquestion/lab
Expand All @@ -78,19 +86,18 @@ See the [contribution guide](CONTRIBUTING.md).
`lab` needs your GitLab information in order to interact with to your GitLab
instance. There are several ways to provide this information to `lab`:

1. Environment variables: `LAB_CORE_HOST`, `LAB_CORE_USER`, `LAB_CORE_TOKEN`
2. Environment variables: `CI_PROJECT_URL`, `CI_REGISTRY_USER`, `CI_JOB_TOKEN`
1. environment variables: `LAB_CORE_HOST`, `LAB_CORE_TOKEN`;
2. environment variables: `CI_PROJECT_URL`, `CI_JOB_TOKEN`;
- Note: these are meant for when `lab` is running within a GitLab CI pipeline
3. HCL config file: `./lab.hcl`
4. HCL config file: `~/.config/lab.hcl`
3. directory-specific configuration file in [HashiCorp configuration language (HCL)](https://github.com/hashicorp/hcl): `./lab.hcl`;
4. user-specific configuration file in HCL: `~/.config/lab.hcl`.

These are checked in order. If no suitable config values are found, `lab` will
prompt for your GitLab information and save it into `~/.config/lab.hcl`.
For example:
```
$ lab
Enter default GitLab host (default: https://gitlab.com):
Enter default GitLab user: zaq
Enter default GitLab token:
```
# Completions
Expand Down Expand Up @@ -134,4 +141,8 @@ alias git=lab
<span property="dct:title">Zaq? Wiedmann</span></a>
has waived all copyright and related or neighboring rights to
<span property="dct:title">Lab</span>.
This work is published from:
<span property="vcard:Country" datatype="dct:ISO3166"
content="US" about="https://github.com/zaquestion/lab">
United States</span>.
</p>
2 changes: 1 addition & 1 deletion cmd/ci_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func Test_getCIRunOptions(t *testing.T) {
[]string{},
nil, // https://gitlab.com/zaquestion/test project ID
"",
"gitlab project not found",
"gitlab project not found, verify you have access to the requested resource",
},
}

Expand Down
43 changes: 29 additions & 14 deletions cmd/ci_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"log"
"os"
"text/tabwriter"
"time"

"github.com/pkg/errors"
"github.com/spf13/cobra"
gitlab "github.com/xanzy/go-gitlab"
"github.com/zaquestion/lab/internal/git"
lab "github.com/zaquestion/lab/internal/gitlab"
)
Expand Down Expand Up @@ -45,37 +47,50 @@ lab ci status --wait`,
pid := rn

w := tabwriter.NewWriter(os.Stdout, 2, 4, 1, byte(' '), 0)
jobs, err := lab.CIJobs(pid, branch)
if err != nil {
log.Fatal(errors.Wrap(err, "failed to find ci jobs"))
}
jobs = latestJobs(jobs)

if len(jobs) == 0 {
return
}

wait, err := cmd.Flags().GetBool("wait")
if err != nil {
log.Fatal(err)
}

var jobs []*gitlab.Job

fmt.Fprintln(w, "Stage:\tName\t-\tStatus")
for {
// fetch all of the CI Jobs from the API
jobs, err = lab.CIJobs(pid, branch)
if err != nil {
log.Fatal(errors.Wrap(err, "failed to find ci jobs"))
}

// filter out old jobs
jobs = latestJobs(jobs)

if len(jobs) == 0 {
log.Fatal("no CI jobs found for branch ", branch, " on remote ", remote)
return
}

// print the status of all current jobs
for _, job := range jobs {
fmt.Fprintf(w, "%s:\t%s\t-\t%s\n", job.Stage, job.Name, job.Status)
}
if !wait {
break
}
if jobs[0].Pipeline.Status != "pending" &&
jobs[0].Pipeline.Status != "running" {

dontWaitForJobsToFinish := !wait ||
(jobs[0].Pipeline.Status != "pending" &&
jobs[0].Pipeline.Status != "running")
if dontWaitForJobsToFinish {
break
}

fmt.Fprintln(w)

// don't spam the api TOO much
time.Sleep(1 * time.Second)
}

fmt.Fprintf(w, "\nPipeline Status: %s\n", jobs[0].Pipeline.Status)
// exit w/ status code 1 to indicate a job failure
if wait && jobs[0].Pipeline.Status != "success" {
os.Exit(1)
}
Expand Down
Loading

0 comments on commit 8e68f5f

Please sign in to comment.