Skip to content
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

dev: remove netlify #4014

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ jobs:
- name: Update Contributors list
run: make update_contributors_list # may take 15 min

- name: Update netlify state hash
run: make update_netlify_state

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,3 @@ expand_website_templates:
update_contributors_list:
cd .github/contributors && npm run all

update_netlify_state:
go run ./scripts/expand_website_templates/main.go -only-state
35 changes: 10 additions & 25 deletions docs/src/docs/contributing/website.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ title: Website architecture

## Technology

We use [Gatsby](https://www.gatsbyjs.org/) for static site generation because sites built with it
are very fast.
We use [Gatsby](https://www.gatsbyjs.org/) for static site generation because sites built with it are very fast.

This framework uses React and JavaScript/TypeScript.

Expand All @@ -16,9 +15,8 @@ The website lives in `docs/` directory of [golangci-lint repository](https://git
## Theme

Initially the site is based on [@rocketseat](https://rocketdocs.netlify.app/) theme.
Later we've merged it's code into `src/@rocketseat` because we needed too much changes
and [gatsby shadowing](https://www.gatsbyjs.org/docs/themes/shadowing/) doesn't
allow shadowing `gatsby-node.js` or `gatsby-config.js`.
Later we've merged its code into `src/@rocketseat` because we needed too much changes
and [gatsby shadowing](https://www.gatsbyjs.org/docs/themes/shadowing/) doesn't allow shadowing `gatsby-node.js` or `gatsby-config.js`.

## Navigation

Expand All @@ -31,22 +29,15 @@ allowing to use `React` components.

## Templating

We use templates like `{.SomeField}` inside our `mdx` files. There templates are expanded
by running `make expand_website_templates` in the root of the repository.
We use templates like `{.SomeField}` inside our `mdx` files.
There templates are expanded by running `make expand_website_templates` in the root of the repository.
It runs script `scripts/expand_website_templates/main.go` that rewrites `mdx` files with replaced templates.

## CDN and DNS

We use [CloudFlare](https://www.cloudflare.com/) for CDN, proxying and DNS management.

## Hosting

We use [Netlify](https://www.netlify.com/) as static website hosting and CD.
It's integrated into our pull requests: if `docs/` directory has changes Netlify
will trigger website rebuild and deploy it's preview for a branch. You can view
it to ensure that everything ok.
We use GitHub Pages as static website hosting and CD.

Netlify deploys the website to production after merging anything to a `master` branch.
GitHub deploys the website to production after merging anything to a `master` branch.

## Local Testing

Expand All @@ -61,16 +52,10 @@ And navigate to `http://localhost:8000` after successful Gatsby build.
There is no need to restart Gatsby server almost for all changes: it supports hot reload.
Also, there is no need to refresh a webpage: hot reload updates changed content on the open page.

## Trigger Website Rebuild
## Website Build

Currently, Netlify triggers rebuild only if anything has changes in `docs/` directory.
But we can add a new linter and need to change a documentation to list the linter.

To do it run
To do it run:

```sh
go run ./scripts/expand_website_templates/main.go -only-state
go run ./scripts/expand_website_templates/main.go
```

It saves a hash of template replacements (that include all linters, configs, etc)
into `docs/template_data.state`.
18 changes: 4 additions & 14 deletions docs/src/docs/contributing/workflow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ title: Contributing Workflow

# Contributing

By participating to this project, you agree to abide our [code of
conduct](https://github.com/golangci/golangci-lint/blob/master/CODE_OF_CONDUCT.md).
By participating in this project, you agree to abide our [code of conduct](https://github.com/golangci/golangci-lint/blob/master/CODE_OF_CONDUCT.md).

## Setup your machine
## Set up your machine

`golangci-lint` is written in [Go](https://go.dev).

Expand Down Expand Up @@ -46,8 +45,7 @@ Push your branch to your `golangci-lint` fork and open a pull request against th

## Pull request checks

First, please, accept [CLA](https://gist.github.com/jirfag/26a39fd375da84b2d5ad4296fecb0668) - [cla assistant](https://cla-assistant.io/) will
make a comment on the pull request about it.
First, please, accept [CLA](https://gist.github.com/jirfag/26a39fd375da84b2d5ad4296fecb0668) - [cla assistant](https://cla-assistant.io/) will make a comment on the pull request about it.

Also, we run a few checks in CI by using GitHub actions, you can see them [here](https://github.com/golangci/golangci-lint/blob/master/.github/workflows/pr.yml).

Expand All @@ -61,19 +59,11 @@ A GitHub action [workflow](https://github.com/golangci/golangci-lint/blob/master
After making a release you need to update:

1. GitHub [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) by running:

```sh
make assets/github-action-config.json
```

2. The latest netlify state (e.g. docs/template_date.state):

```sh
make update_netlify_state
```

3. Contributors list

2. Contributors list:
```sh
make update_contributors_list # may take 15 min
```
1 change: 1 addition & 0 deletions docs/static/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golangci-lint.run
2 changes: 0 additions & 2 deletions docs/template_data.state

This file was deleted.

23 changes: 0 additions & 23 deletions netlify.toml

This file was deleted.

36 changes: 1 addition & 35 deletions scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package main

import (
"bytes"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io"
"log"
Expand All @@ -29,48 +26,17 @@ import (

const listItemPrefix = "list-item-"

var stateFilePath = filepath.Join("docs", "template_data.state")

func main() {
var onlyWriteState bool
flag.BoolVar(&onlyWriteState, "only-state", false, fmt.Sprintf("Only write hash of state to %s and exit", stateFilePath))
flag.Parse()

replacements, err := buildTemplateContext()
if err != nil {
log.Fatalf("Failed to build template context: %s", err)
}

if err = updateStateFile(replacements); err != nil {
log.Fatalf("Failed to update state file: %s", err)
}

if onlyWriteState {
return
}

if err := rewriteDocs(replacements); err != nil {
log.Fatalf("Failed to rewrite docs: %s", err)
}
log.Print("Successfully expanded templates")
}

func updateStateFile(replacements map[string]string) error {
replBytes, err := json.Marshal(replacements)
if err != nil {
return fmt.Errorf("failed to json marshal replacements: %w", err)
}

h := sha256.New()
if _, err := h.Write(replBytes); err != nil {
return err
}

contentBuf := bytes.NewBufferString("This file stores hash of website templates to trigger " +
"Netlify rebuild when something changes, e.g. new linter is added.\n")
contentBuf.WriteString(hex.EncodeToString(h.Sum(nil)))

return renameio.WriteFile(stateFilePath, contentBuf.Bytes(), os.ModePerm)
log.Print("Successfully expanded templates")
}

func rewriteDocs(replacements map[string]string) error {
Expand Down