Skip to content

Commit

Permalink
Create website for maintainers and contributors
Browse files Browse the repository at this point in the history
See website/content/about/contributing.md (or /about/contributing) for
how to contribute to the website.

This uses a fork of github.com/cncf/contribute until we have approved
the POC and merged my branch with required changes to work with Hugo.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
  • Loading branch information
carolynvs committed Mar 29, 2021
1 parent 1ce07a1 commit c5bba84
Show file tree
Hide file tree
Showing 57 changed files with 15,627 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!website
website/public
website/go.local.mod
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "website/themes/docsy"]
path = website/themes/docsy
url = https://github.com/google/docsy.git
5 changes: 4 additions & 1 deletion CHARTER.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CNCF SIG Contributor Strategy Charter
---
title: CNCF SIG Contributor Strategy Charter
linkTitle: Charter
---

Primary Authors: Paris Pittman, Josh Berkus

Expand Down
21 changes: 16 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,32 @@ show...:*

🛬Thanks for landing here! There's a good chance you want to help the
contributor side of the code in one of our working groups, get involved on a
regular basis, or simply be curious, no matter your reason are excited to have
regular basis, or simply be curious, no matter your reason, we are excited to have
you.

This [SIG] (Special Interest Group) is an extension of the [TOC] that works to
build programs and guidance to help scale and grow open source communities. We
work in two CNCF GitHub repositories:

🆕[cncf/sig-contributor-strategy]
contains our meta docs that cover our governance, how we operate, and resources that we
collect along the way.
collect along the way. The [website/content] directory contains the source for the
web pages at [contribute.cncf.io/maintainers][maintainers] and is advice for people who
are running and maintaining CNCF projects.

🔜[cncf/contribute]
will house contributing information and guidance that we provide to CNCF
projects for contributor strategy topics. The intention is to grow this as a
resource for all contributors - aspiring, current, and maintainers.
houses contributing information and guidance for people who are contributors
or aspire to be contributors to CNCF projects. This content is available on our
website at [contribute.cncf.io/contributors][contributors].

Our [charter] describes our mission and initial scope of what we’d like to
accomplish. Each of our members are closely involved with at least one CNCF
project; we are here to learn as much as those we serve.

## Contribute to the website

Read our [contributing guide] for details on how to contribute content for [contribute.cncf.io].

## Ground Rules
We very much welcome everyone on any of our [communication channels] including
through GitHub Issues and Pull Requests (PRs) and ask all contributors to
Expand Down Expand Up @@ -121,3 +128,7 @@ https://www.firsttimersonly.com/
[cncf/sig-contributor-strategy]: https://github.com/cncf/sig-contributor-strategy
[maintainers circle]: https://github.com/cncf/sig-contributor-strategy/issues/1
[4th Thursday meeting of each month]: https://github.com/cncf/sig-contributor-strategy/blob/master/README.md#meetings
[website/content]: website/content/
[contributing guide]: https://contribute.cncf.io/about/contributing/
[maintainers]: https://contribute.cncf.io/maintainers
[contributors]: https://contribute.cncf.io/contributors
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2021 The Linux Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ channels:

- Paris Pittman ([@parispittman](https://github.com/parispittman)), Google
- Josh Berkus ([@jberkus](https://github.com/jberkus)), Red Hat
- Gerred Dillon ([@gerred](https://github.com/gerred)), D2iQ
- Stephen Augustus ([@justaugustus](https://github.com/justaugustus)), VMware

### TOC Liaisons

Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/cncf/sig-contributor-strategy

go 1.15

require (
github.com/carolynvs/magex v0.4.0
github.com/magefile/mage v1.11.0
github.com/pkg/errors v0.9.1
)
17 changes: 17 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
github.com/carolynvs/magex v0.4.0 h1:BEcWFju5JNtfHcyvoENZzzPObpv0IHZnhxkOT4hKv4M=
github.com/carolynvs/magex v0.4.0/go.mod h1:2UQe/9ipQIsGcvwavGLv/c2IEJG32zu0iafZhUlk/Z4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5 changes: 0 additions & 5 deletions governance/docs/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// +build ignore

package main

import (
"os"

"github.com/magefile/mage/mage"
)

// This file allows someone to run mage commands without mage installed
// by running `go run mage.go TARGET`.
// See https://magefile.org/zeroinstall/
func main() { os.Exit(mage.Main()) }
264 changes: 264 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
// +build mage

// This is a magefile, and is a "makefile for go".
// See https://magefile.org/
package main

import (
"context"
"fmt"
"io"
"log"
"os"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/carolynvs/magex/pkg"
"github.com/carolynvs/magex/shx"
"github.com/carolynvs/magex/xplat"
"github.com/magefile/mage/mg"
"github.com/pkg/errors"
)

// Default target to run when none is specified
// If not set, running mage will list available targets
var (
Default = Preview
contributeRepo = "../contribute"
)

const (
containerName = "sig-contributor-strategy"
img = containerName
)

// Ensure Mage is installed and on the PATH.
func EnsureMage() error {
return pkg.EnsureMage("")
}

// Compile the website to website/public.
func Build() error {
mg.Deps(clean, buildImage)

// Build the volume mount for a local contribute repo, if present
contribMount, goModMount, err := useLocalContributeModule()
if err != nil {
return err
}

pwd, _ := os.Getwd()
return shx.Command("docker","run", "--rm", "-v", pwd+":/src",
contribMount, goModMount, containerName, "--debug", "--verbose").CollapseArgs().RunV()
}

// Run a local server to preview the website and watch for changes.
func Preview() error {
mg.Deps(clean, buildImage)

// Build the volume mount for a local contribute repo, if present
contribMount, goModMount, err := useLocalContributeModule()
if err != nil {
return err
}

port := getPort()
pwd, _ := os.Getwd()
err = shx.Command("docker", "run", "-d", "-v", pwd+":/src",
contribMount, goModMount, "-p", port+":1313",
"--name", containerName, img, "server", "--debug", "--verbose",
"--buildDrafts", "--buildFuture", "--noHTTPCache", "--watch", "--bind=0.0.0.0").CollapseArgs().RunV()
if err != nil {
return errors.Wrap(err, "could not run website container")
}

err = awaitContainer(containerName, "Web Server is available")
if err != nil {
return errors.Wrap(err, "error waiting for the website to become ready")
}

url := "http://localhost:" + getPort()
return errors.Wrap(openURL(url), "could not open the website in a browser")
}

func Logs() error {
return shx.RunV("docker", "logs", "-f", img)
}

// Use hugo in a docker container.
func Hugo() error {
pwd, _ := os.Getwd()
cmd := shx.Command("docker", "run", "--rm", "-it", "-v", pwd+":/src", "-w", "/src/website", img, "shell").
Stdout(os.Stdout)
cmd.Cmd.Stdin = os.Stdin
_, _, err := cmd.Exec()
return errors.Wrap(err, "could not start hugo in a container")
}

func Deploy() error {
mg.Deps(docsy, syncGoMod)

return shx.RunV("hugo", "-s", "website", "--debug", "--verbose")
}

func DeployPreview() error {
mg.Deps(docsy, syncGoMod)

return shx.RunV("hugo", "-s", "website", "--debug", "--verbose", "-b", getBaseUrl())
}

func syncGoMod() error {
return shx.RunV("go", "mod", "download")
}

func getBaseUrl() string {
return os.Getenv("DEPLOY_PRIME_URL" + "/")
}

// Create go.local.mod with any appropriate replace statements, and
// returns the local contribute mount flag if present.
func useLocalContributeModule() (contribMount string, goModMount string, err error) {
// Edit a copy of website/go.mod so that it doesn't always show up as modified in git
pwd, _ := os.Getwd()
localGoMod := filepath.Join(pwd, "website/go.local.mod")
err = copyFile("website/go.mod", localGoMod)
if err != nil {
return "", "", err
}
goModMount = fmt.Sprintf("-v=%s:/src/website/go.mod", localGoMod)

err = shx.RunV("docker", "run", "--rm", "--entrypoint", "go",
"-v", pwd+":/src", goModMount, "-w", "/src/website", img,
"mod", "download")
if err != nil {
return "", "", errors.Wrap(err, "could not modify resolve go.mod")
}

// Only mount the local repo if it exists, otherwise use the one on github
if mg.Verbose() {
fmt.Println("Checking for a local copy of github.com/cncf/contribute at", contributeRepo)
}
if repo, ok := os.LookupEnv("CONTRIBUTE_REPO"); ok {
contributeRepo = repo
}
contributeRepo, _ := filepath.Abs(contributeRepo)
_, err = os.Stat(contributeRepo)
if err != nil {
return "", goModMount, nil
}

log.Println("Using your local copy of github.com/cncf/contribute ->", contributeRepo)
err = shx.RunV("docker", "run", "--rm", "--entrypoint", "go",
"-v", pwd+":/src", goModMount, "-w", "/src/website", img,
"mod", "edit", "-replace", "github.com/cncf/contribute=/src/contribute")
if err != nil {
return "", "", errors.Wrap(err, "could not modify go.mod to use your local copy of github.com/cncf/contribute")
}

contribMount = fmt.Sprintf("-v=%s:/src/contribute", contributeRepo)
return contribMount, goModMount, nil
}

func copyFile(src string, dest string) error {
s, err := os.Open(src)
if err != nil {
return errors.Wrapf(err, "could not open %s", src)
}

d, err := os.Create(dest)
if err != nil {
return errors.Wrapf(err, "could not create %s", dest)
}

_, err = io.Copy(d, s)
return errors.Wrapf(err, "could not copy %s to %s", src, dest)
}

func openURL(url string) error {
shell := xplat.DetectShell()
if shell == "msystem" {
return shx.RunE("cmd", "/C", "open "+url)
}
if runtime.GOOS == "windows" {
return shx.RunE("powershell", "Start-Process", url)
}
return shx.RunE(shell, "-c", "open "+url)
}

func getPort() string {
port := os.Getenv("PORT")
if port == "" {
port = "1313"
}
return port
}

func buildImage() error {
mg.Deps(docsy)
err := shx.RunE("docker", "build", "-t", img,
"-f", "website/Dockerfile", ".")
return errors.Wrap(err, "could not build website image")
}

func docsy() error {
_, err := os.Stat("website/themes/docsy")
if err != nil {
if os.IsNotExist(err) {
return shx.RunE("git", "submodule", "update", "--init", "--recursive", "--force")
}
return errors.Wrap(err, "could not clone the docsy theme")
}

return nil
}

func containerExists(name string) bool {
output, err := shx.Output("docker", "ps", "--all", "--filter", "name="+name)
return err == nil && strings.Contains(output, name)
}

func removeContainer(name string) error {
return shx.RunV("docker", "rm", "-f", name)
}

func awaitContainer(name string, logSearch string) error {
cxt, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

for {
select {
case <-cxt.Done():
return errors.Errorf("timeout waiting for container %s to become ready", name)
default:
logs, err := shx.Output("docker", "logs", name)
if err != nil {
return errors.Wrapf(err, "could not get logs for container %s", name)
}

if strings.Contains(logs, logSearch) {
return nil
}

if mg.Verbose() {
fmt.Println(logs)
}

time.Sleep(time.Second)
}
}
}

func clean() error {
err := os.RemoveAll("website/public")
if err != nil {
return errors.Wrap(err, "could not remove website/public")
}

if containerExists(containerName) {
return removeContainer(containerName)
}

return nil
}
Loading

0 comments on commit c5bba84

Please sign in to comment.