Skip to content

Remove goreleaser in favor of build scripts #2143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bc06a6f
chore: write build_go.sh script and dependencies
deansheather Jun 7, 2022
850bc82
chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
e847230
fixup! chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
4edb649
fixup! chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
4ed419c
merge main
deansheather Jun 8, 2022
cef0221
chore: add scripts for packages
deansheather Jun 8, 2022
64f9648
chore: add scripts for building a docker image
deansheather Jun 8, 2022
998bc31
chore: add docker multi-arch script and release script
deansheather Jun 9, 2022
46b5d79
fixup! chore: add docker multi-arch script and release script
deansheather Jun 9, 2022
9e279a9
chore: fix indenting
deansheather Jun 9, 2022
4885076
chore: update makefile to use new build scripts
deansheather Jun 9, 2022
044780d
chore: update release workflow to use new build scripts
deansheather Jun 10, 2022
59cd2c7
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
d1edee5
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
4f03e37
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
5c9dd9e
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
e09edfd
fixup! chore: update release workflow to use new build scripts
deansheather Jun 13, 2022
4dd6f4d
chore: add dependency checks to release scripts
deansheather Jun 13, 2022
72d8b50
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
17cda1f
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
6a4bc44
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
e150438
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
449a1a1
chore: make dependency checks nicer
deansheather Jun 14, 2022
ba78076
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
a19ef36
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
94a6fcd
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
c524507
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
48eaa18
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
ce3f4f5
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
4886542
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
d4631ad
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
a0c9a96
chore: integrate docker into pipeline
deansheather Jun 15, 2022
0907c37
fixup! chore: integrate docker into pipeline
deansheather Jun 15, 2022
4a94e25
fixup! chore: integrate docker into pipeline
deansheather Jun 16, 2022
37badc3
Merge branch 'main' into remove-goreleaser
deansheather Jun 16, 2022
173031f
chore: add version checks to lib.sh
deansheather Jun 16, 2022
ae48f20
fixup! chore: add version checks to lib.sh
deansheather Jun 16, 2022
d8a624c
fixup! chore: add version checks to lib.sh
deansheather Jun 16, 2022
6f2b997
Merge branch 'main' into remove-goreleaser
deansheather Jun 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into remove-goreleaser
  • Loading branch information
deansheather committed Jun 16, 2022
commit 37badc3d63bcbe3bfed594507cb2a041b177de12
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ coderd/database/dump.sql linguist-generated=true
peerbroker/proto/*.go linguist-generated=true
provisionerd/proto/*.go linguist-generated=true
provisionersdk/proto/*.go linguist-generated=true
*.tfplan.json linguist-generated=true
*.tfstate.json linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
4 changes: 2 additions & 2 deletions .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-coverpkg=./...,github.com/coder/coder/codersdk
-timeout=3m -count=$GOCOUNT -short -failfast
-timeout=5m -count=$GOCOUNT -short -failfast
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: I wonder if we should instead just use the Makefile target so we don't need to keep this in sync?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a comment on the merge commit since I didn't touch this in my PR. Feel free to fix this in a separate PR


- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
Expand Down Expand Up @@ -315,7 +315,7 @@ jobs:
deploy:
name: "deploy"
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 30
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
permissions:
contents: read
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"kirsle",
"ldflags",
"manifoldco",
"mapstructure",
"mattn",
"mitchellh",
"moby",
Expand All @@ -62,14 +63,17 @@
"sdktrace",
"Signup",
"sourcemapped",
"Srcs",
"stretchr",
"TCGETS",
"tcpip",
"TCSETS",
"templateversions",
"testdata",
"testid",
"tfexec",
"tfjson",
"tfplan",
"tfstate",
"trimprefix",
"turnconn",
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ test: test-clean

test-postgres: test-clean
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \
-covermode=atomic -coverprofile="gotests.coverage" -timeout=5m \
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \
-coverpkg=./...,github.com/coder/coder/codersdk \
-count=1 -parallel=1 -race -failfast
-count=1 -race -failfast
.PHONY: test-postgres

test-postgres-docker:
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Coder creates remote development machines so your team can develop from anywhere
> **Note**:
> Coder is in an alpha state. [Report issues here](https://github.com/coder/coder/issues/new).

There are a few ways to install Coder: [install script](./docs/install.md#installsh) (macOS, Linux), [docker-compose](./docs/install.md#docker-compose), or [manually](./docs/install.md#manual) via the latest release (macOS, Windows, and Linux).
There are a few ways to install Coder: [install script](https://coder.com/docs/coder-oss/latest/install#installsh) (macOS, Linux), [docker-compose](https://coder.com/docs/coder-oss/latest/install#docker-compose), or [manually](https://coder.com/docs/coder-oss/latest/install#manual) via the latest release (macOS, Windows, and Linux).

If you use the install script, you can preview what occurs during the install process:

Expand All @@ -47,21 +47,25 @@ To install, run:
curl -fsSL https://coder.com/install.sh | sh
```

Once installed, you can run a temporary deployment in dev mode (all data is in-memory and destroyed on exit):
Once installed, you can start a production deployment with a single command:

```sh
coder server --dev
# Automatically sets up an external access URL on *.try.coder.app
coder server --tunnel

# Requires a PostgreSQL instance and external access URL
coder server --postgres-url <url> --access-url <url>
```

Use `coder --help` to get a complete list of flags and environment variables. Use our [quickstart guide](./docs/quickstart.md) for a full walkthrough.
Use `coder --help` to get a complete list of flags and environment variables. Use our [quickstart guide](https://coder.com/docs/coder-oss/latest/quickstart) for a full walkthrough.

## Documentation

Visit our docs [here](./docs/index.md).
Visit our docs [here](https://coder.com/docs/coder-oss).

## Comparison

Please file [an issue](https://github.com/coder/coder/issues/new) if any information is out of date. Also refer to: [What Coder is not](./docs/about.md#what-coder-is-not).
Please file [an issue](https://github.com/coder/coder/issues/new) if any information is out of date. Also refer to: [What Coder is not](https://coder.com/docs/coder-oss/latest/index#what-coder-is-not).

| Tool | Type | Delivery Model | Cost | Environments |
| :---------------------------------------------------------- | :------- | :----------------- | :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -82,6 +86,6 @@ Join our community on [Discord](https://discord.gg/coder) and [Twitter](https://

## Contributing

Read the [contributing docs](./docs/CONTRIBUTING.md).
Read the [contributing docs](https://coder.com/docs/coder-oss/latest/CONTRIBUTING).

Find our list of contributors [here](./docs/CONTRIBUTORS.md).
157 changes: 123 additions & 34 deletions cli/autostart.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,41 @@ package cli

import (
"fmt"
"os"
"strings"
"time"

"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/coder/coder/coderd/autobuild/schedule"
"github.com/coder/coder/coderd/util/ptr"
"github.com/coder/coder/coderd/util/tz"
"github.com/coder/coder/codersdk"
)

const autostartDescriptionLong = `To have your workspace build automatically at a regular time you can enable autostart.
When enabling autostart, provide the minute, hour, and day(s) of week.
The default schedule is at 09:00 in your local timezone (TZ env, UTC by default).
When enabling autostart, enter a schedule in the format: <start-time> [day-of-week] [location].
* Start-time (required) is accepted either in 12-hour (hh:mm{am|pm}) format, or 24-hour format hh:mm.
* Day-of-week (optional) allows specifying in the cron format, e.g. 1,3,5 or Mon-Fri.
Aliases such as @daily are not supported.
Default: * (every day)
* Location (optional) must be a valid location in the IANA timezone database.
If omitted, we will fall back to either the TZ environment variable or /etc/localtime.
You can check your corresponding location by visiting https://ipinfo.io - it shows in the demo widget on the right.
`

func autostart() *cobra.Command {
autostartCmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "autostart enable <workspace>",
Use: "autostart set <workspace> <start-time> [day-of-week] [location]",
Short: "schedule a workspace to automatically start at a regular time",
Long: autostartDescriptionLong,
Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
Example: "coder autostart set my-workspace 9:30AM Mon-Fri Europe/Dublin",
}

autostartCmd.AddCommand(autostartShow())
autostartCmd.AddCommand(autostartEnable())
autostartCmd.AddCommand(autostartDisable())
autostartCmd.AddCommand(autostartSet())
autostartCmd.AddCommand(autostartUnset())

return autostartCmd
}
Expand Down Expand Up @@ -60,13 +69,12 @@ func autostartShow() *cobra.Command {
}

next := validSchedule.Next(time.Now())
loc, _ := time.LoadLocation(validSchedule.Timezone())

_, _ = fmt.Fprintf(cmd.OutOrStdout(),
"schedule: %s\ntimezone: %s\nnext: %s\n",
validSchedule.Cron(),
validSchedule.Timezone(),
next.In(loc),
validSchedule.Location(),
next.In(validSchedule.Location()),
)

return nil
Expand All @@ -75,23 +83,17 @@ func autostartShow() *cobra.Command {
return cmd
}

func autostartEnable() *cobra.Command {
// yes some of these are technically numbers but the cron library will do that work
var autostartMinute string
var autostartHour string
var autostartDayOfWeek string
var autostartTimezone string
func autostartSet() *cobra.Command {
cmd := &cobra.Command{
Use: "enable <workspace_name> <schedule>",
Args: cobra.ExactArgs(1),
Use: "set <workspace_name> <start-time> [day-of-week] [location]",
Args: cobra.RangeArgs(2, 4),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}

spec := fmt.Sprintf("CRON_TZ=%s %s %s * * %s", autostartTimezone, autostartMinute, autostartHour, autostartDayOfWeek)
validSchedule, err := schedule.Weekly(spec)
sched, err := parseCLISchedule(args[1:]...)
if err != nil {
return err
}
Expand All @@ -102,32 +104,30 @@ func autostartEnable() *cobra.Command {
}

err = client.UpdateWorkspaceAutostart(cmd.Context(), workspace.ID, codersdk.UpdateWorkspaceAutostartRequest{
Schedule: &spec,
Schedule: ptr.Ref(sched.String()),
})
if err != nil {
return err
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will automatically start at %s.\n\n", workspace.Name, validSchedule.Next(time.Now()))

schedNext := sched.Next(time.Now())
_, _ = fmt.Fprintf(cmd.OutOrStdout(),
"%s will automatically start at %s %s (%s)\n",
workspace.Name,
schedNext.In(sched.Location()).Format(time.Kitchen),
sched.DaysOfWeek(),
sched.Location().String(),
)
return nil
},
}

cmd.Flags().StringVar(&autostartMinute, "minute", "0", "autostart minute")
cmd.Flags().StringVar(&autostartHour, "hour", "9", "autostart hour")
cmd.Flags().StringVar(&autostartDayOfWeek, "days", "1-5", "autostart day(s) of week")
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
}
cmd.Flags().StringVar(&autostartTimezone, "tz", tzEnv, "autostart timezone")
return cmd
}

func autostartDisable() *cobra.Command {
func autostartUnset() *cobra.Command {
return &cobra.Command{
Use: "disable <workspace_name>",
Use: "unset <workspace_name>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
Expand All @@ -147,9 +147,98 @@ func autostartDisable() *cobra.Command {
return err
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will no longer automatically start.\n\n", workspace.Name)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s will no longer automatically start.\n", workspace.Name)

return nil
},
}
}

var errInvalidScheduleFormat = xerrors.New("Schedule must be in the format Mon-Fri 09:00AM America/Chicago")
var errInvalidTimeFormat = xerrors.New("Start time must be in the format hh:mm[am|pm] or HH:MM")
var errUnsupportedTimezone = xerrors.New("The location you provided looks like a timezone. Check https://ipinfo.io for your location.")

// parseCLISchedule parses a schedule in the format HH:MM{AM|PM} [DOW] [LOCATION]
func parseCLISchedule(parts ...string) (*schedule.Schedule, error) {
// If the user was careful and quoted the schedule, un-quote it.
// In the case that only time was specified, this will be a no-op.
if len(parts) == 1 {
parts = strings.Fields(parts[0])
}
var loc *time.Location
dayOfWeek := "*"
t, err := parseTime(parts[0])
if err != nil {
return nil, err
}
hour, minute := t.Hour(), t.Minute()

// Any additional parts get ignored.
switch len(parts) {
case 3:
dayOfWeek = parts[1]
loc, err = time.LoadLocation(parts[2])
if err != nil {
_, err = time.Parse("MST", parts[2])
if err == nil {
return nil, errUnsupportedTimezone
}
return nil, xerrors.Errorf("Invalid timezone %q specified: a valid IANA timezone is required", parts[2])
}
case 2:
// Did they provide day-of-week or location?
if maybeLoc, err := time.LoadLocation(parts[1]); err != nil {
// Assume day-of-week.
dayOfWeek = parts[1]
} else {
loc = maybeLoc
}
case 1: // already handled
default:
return nil, errInvalidScheduleFormat
}

// If location was not specified, attempt to automatically determine it as a last resort.
if loc == nil {
loc, err = tz.TimezoneIANA()
if err != nil {
return nil, xerrors.Errorf("Could not automatically determine your timezone")
}
}

sched, err := schedule.Weekly(fmt.Sprintf(
"CRON_TZ=%s %d %d * * %s",
loc.String(),
minute,
hour,
dayOfWeek,
))
if err != nil {
// This will either be an invalid dayOfWeek or an invalid timezone.
return nil, xerrors.Errorf("Invalid schedule: %w", err)
}

return sched, nil
}

func parseTime(s string) (time.Time, error) {
// Try a number of possible layouts.
for _, layout := range []string{
time.Kitchen, // 03:04PM
"03:04pm",
"3:04PM",
"3:04pm",
"15:04",
"1504",
"03PM",
"03pm",
"3PM",
"3pm",
} {
t, err := time.Parse(layout, s)
if err == nil {
return t, nil
}
}
return time.Time{}, errInvalidTimeFormat
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.