dev: remove netlify (#4014)

This commit is contained in:
Ludovic Fernandez 2023-08-17 16:35:40 +02:00 committed by GitHub
parent 8000abaf0e
commit 0f8b1e2570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 104 deletions

View File

@ -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:

View File

@ -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

View File

@ -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.
@ -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
@ -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
@ -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`.

View File

@ -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).
@ -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).
@ -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
docs/static/CNAME vendored Normal file
View File

@ -0,0 +1 @@
golangci-lint.run

View File

@ -1,2 +0,0 @@
This file stores hash of website templates to trigger Netlify rebuild when something changes, e.g. new linter is added.
3dd55e7301e3b3c9fab930bcc28a44db056ccefa15befc5a360e764d1aad1d48

View File

@ -1,23 +0,0 @@
[context.production.environment]
GO_VERSION = "1.19"
NODE_VERSION = "17"
# TODO https://github.com/golangci/golangci-lint/pull/2904#issuecomment-1146870535
# NPM_FLAGS = "--legacy-peer-deps"
# NPM_FLAGS = "--force"
NPM_VERSION = "8.5.5"
[context.deploy-preview.environment]
GO_VERSION = "1.19"
NODE_VERSION = "17"
# TODO https://github.com/golangci/golangci-lint/pull/2904#issuecomment-1146870535
# NPM_FLAGS = "--legacy-peer-deps"
# NPM_FLAGS = "--force"
NPM_VERSION = "8.5.5"
[context.branch-deploy.environment]
GO_VERSION = "1.19"
NODE_VERSION = "17"
# TODO https://github.com/golangci/golangci-lint/pull/2904#issuecomment-1146870535
# NPM_FLAGS = "--legacy-peer-deps"
# NPM_FLAGS = "--force"
NPM_VERSION = "8.5.5"

View File

@ -2,10 +2,7 @@ package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io"
"log"
@ -29,50 +26,19 @@ 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)
}
func rewriteDocs(replacements map[string]string) error {
madeReplacements := map[string]bool{}
err := filepath.Walk(filepath.Join("docs", "src", "docs"),