From 78973eaf3f2a590b16081b4d1d23b74bcb7fa8d1 Mon Sep 17 00:00:00 2001 From: Bryan Date: Mon, 3 Jan 2022 18:54:27 -0800 Subject: [PATCH] chore: Initial GHA workflow (#1) This implements an initial GitHub Actions workflow for us - to be run on PRs and on `main` commits. This just implements a really simple `style/fmt` check - running `prettier` on the `README.md`. I assumed we'll stick with using a top-level `Makefile` for commands like in `m` and `link` - but open to alternatives, too! Since I was adding a `package.json` and `node_modules` for this, I realized we were missing `.gitignore`s, so I added some a subset of the ignore files from `coder/m` --- .eslintignore | 4 ++ .github/workflows/coder.yaml | 100 +++++++++++++++++++++++++++++++++++ .gitignore | 13 +++++ .prettierignore | 7 +++ Makefile | 12 +++++ README.md | 6 ++- package.json | 13 +++++ yarn.lock | 8 +++ 8 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 .eslintignore create mode 100644 .github/workflows/coder.yaml create mode 100644 .gitignore create mode 100644 .prettierignore create mode 100644 Makefile create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..bee3ca2bf9 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +############################################################################### +# COPY PASTA OF .gitignore +############################################################################### +node_modules \ No newline at end of file diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml new file mode 100644 index 0000000000..6fd8ae9737 --- /dev/null +++ b/.github/workflows/coder.yaml @@ -0,0 +1,100 @@ +name: coder + +on: + push: + branches: + - main + - "release/*" + tags: + - "*" + + pull_request: + branches: + - main + - "release/*" + + workflow_dispatch: + +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + +jobs: + style: + name: "style/${{ matrix.style }}" + runs-on: ubuntu-latest + strategy: + matrix: + style: + - fmt + fail-fast: false + permissions: + actions: write # for cancel-workflow-action + contents: read + steps: + - name: Cancel previous runs + if: github.event_name == 'pull_request' + uses: styfle/cancel-workflow-action@0.9.1 + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + + - name: Cache Node + id: cache-node + uses: actions/cache@v2 + with: + path: | + **/node_modules + .eslintcache + key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }} + + - name: Install node_modules + run: yarn install + + - name: "make ${{ matrix.style }}" + run: "make --output-sync -j ${{ matrix.style }}" + + test-go: + name: "test/go" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: "^1.17" + + # Check that go is available + # TODO: Implement actual test run + - run: go version + + test-js: + name: "test/js" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: "14" + + # Check that node is available + # TODO: Implement actual test run + - run: node --version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..cc8a97a2c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +############################################################################### +# NOTICE # +# If you change this file, kindly copy-pasta your change into .prettierignore # +# and .eslintignore as well. See the following discussions to understand why # +# we have to resort to this duplication (at least for now): # +# # +# https://github.com/prettier/prettier/issues/8048 # +# https://github.com/prettier/prettier/issues/8506 # +# https://github.com/prettier/prettier/issues/8679 # +############################################################################### + +node_modules +.eslintcache \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..c7f4591f84 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +############################################################################### +# COPY PASTA OF .gitignore +# https://github.com/prettier/prettier/issues/8048 +# https://github.com/prettier/prettier/issues/8506 +# https://github.com/prettier/prettier/issues/8679 +############################################################################### +node_modules \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6404f93a56 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +fmt/prettier: + @echo "--- prettier" +# Avoid writing files in CI to reduce file write activity +ifdef CI + yarn run format:check +else + yarn run format:write +endif +.PHONY: fmt/prettier + +fmt: fmt/prettier +.PHONY: fmt \ No newline at end of file diff --git a/README.md b/README.md index cdc507907e..be1a04b98f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ +[![coder](https://github.com/coder/coder/actions/workflows/coder.yaml/badge.svg)](https://github.com/coder/coder/actions/workflows/coder.yaml) +[![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder) + # Coder v2 This repository contains source code for Coder V2. Additional documentation: + - [Workspaces V2 RFC](https://www.notion.so/coderhq/b48040da8bfe46eca1f32749b69420dd?v=a4e7d23495094644b939b08caba8e381&p=e908a8cd54804ddd910367abf03c8d0a) ## Directory Structure -- `.github/`: Settings for [Dependabot for updating dependencies](https://docs.github.com/en/code-security/supply-chain-security/customizing-dependency-updates) and [build/deploy pipelines with GitHub Actions](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions). \ No newline at end of file +- `.github/`: Settings for [Dependabot for updating dependencies](https://docs.github.com/en/code-security/supply-chain-security/customizing-dependency-updates) and [build/deploy pipelines with GitHub Actions](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions). diff --git a/package.json b/package.json new file mode 100644 index 0000000000..eb099b3491 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "coder-v2", + "description": "Coder V2 (Workspaces V2)", + "repository": "https://github.com/coder/coder", + "private": true, + "scripts": { + "format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'", + "format:write": "prettier --write '**/*.{css,htmljs,json,jsx,md,ts,tsx,yaml,yml}'" + }, + "devDependencies": { + "prettier": "2.5.1" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000000..f5d535fc74 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +prettier@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" + integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==