Skip to content

Commit 78973ea

Browse files
authored
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`
1 parent 8203bf0 commit 78973ea

File tree

8 files changed

+162
-1
lines changed

8 files changed

+162
-1
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
###############################################################################
2+
# COPY PASTA OF .gitignore
3+
###############################################################################
4+
node_modules

.github/workflows/coder.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: coder
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "release/*"
8+
tags:
9+
- "*"
10+
11+
pull_request:
12+
branches:
13+
- main
14+
- "release/*"
15+
16+
workflow_dispatch:
17+
18+
permissions:
19+
actions: none
20+
checks: none
21+
contents: read
22+
deployments: none
23+
issues: none
24+
packages: none
25+
pull-requests: none
26+
repository-projects: none
27+
security-events: none
28+
statuses: none
29+
30+
jobs:
31+
style:
32+
name: "style/${{ matrix.style }}"
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
style:
37+
- fmt
38+
fail-fast: false
39+
permissions:
40+
actions: write # for cancel-workflow-action
41+
contents: read
42+
steps:
43+
- name: Cancel previous runs
44+
if: github.event_name == 'pull_request'
45+
uses: styfle/cancel-workflow-action@0.9.1
46+
47+
- name: Checkout
48+
uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 0
51+
submodules: true
52+
53+
- name: Cache Node
54+
id: cache-node
55+
uses: actions/cache@v2
56+
with:
57+
path: |
58+
**/node_modules
59+
.eslintcache
60+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
61+
62+
- name: Install node_modules
63+
run: yarn install
64+
65+
- name: "make ${{ matrix.style }}"
66+
run: "make --output-sync -j ${{ matrix.style }}"
67+
68+
test-go:
69+
name: "test/go"
70+
runs-on: ${{ matrix.os }}
71+
strategy:
72+
matrix:
73+
os:
74+
- ubuntu-latest
75+
- macos-latest
76+
- windows-latest
77+
steps:
78+
- uses: actions/checkout@v2
79+
80+
- uses: actions/setup-go@v2
81+
with:
82+
go-version: "^1.17"
83+
84+
# Check that go is available
85+
# TODO: Implement actual test run
86+
- run: go version
87+
88+
test-js:
89+
name: "test/js"
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v2
93+
94+
- uses: actions/setup-node@v2
95+
with:
96+
node-version: "14"
97+
98+
# Check that node is available
99+
# TODO: Implement actual test run
100+
- run: node --version

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
###############################################################################
2+
# NOTICE #
3+
# If you change this file, kindly copy-pasta your change into .prettierignore #
4+
# and .eslintignore as well. See the following discussions to understand why #
5+
# we have to resort to this duplication (at least for now): #
6+
# #
7+
# https://github.com/prettier/prettier/issues/8048 #
8+
# https://github.com/prettier/prettier/issues/8506 #
9+
# https://github.com/prettier/prettier/issues/8679 #
10+
###############################################################################
11+
12+
node_modules
13+
.eslintcache

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
###############################################################################
2+
# COPY PASTA OF .gitignore
3+
# https://github.com/prettier/prettier/issues/8048
4+
# https://github.com/prettier/prettier/issues/8506
5+
# https://github.com/prettier/prettier/issues/8679
6+
###############################################################################
7+
node_modules

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fmt/prettier:
2+
@echo "--- prettier"
3+
# Avoid writing files in CI to reduce file write activity
4+
ifdef CI
5+
yarn run format:check
6+
else
7+
yarn run format:write
8+
endif
9+
.PHONY: fmt/prettier
10+
11+
fmt: fmt/prettier
12+
.PHONY: fmt

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
[![coder](https://github.com/coder/coder/actions/workflows/coder.yaml/badge.svg)](https://github.com/coder/coder/actions/workflows/coder.yaml)
2+
[![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder)
3+
14
# Coder v2
25

36
This repository contains source code for Coder V2. Additional documentation:
7+
48
- [Workspaces V2 RFC](https://www.notion.so/coderhq/b48040da8bfe46eca1f32749b69420dd?v=a4e7d23495094644b939b08caba8e381&p=e908a8cd54804ddd910367abf03c8d0a)
59

610
## Directory Structure
711

8-
- `.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).
12+
- `.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).

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "coder-v2",
3+
"description": "Coder V2 (Workspaces V2)",
4+
"repository": "https://github.com/coder/coder",
5+
"private": true,
6+
"scripts": {
7+
"format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
8+
"format:write": "prettier --write '**/*.{css,htmljs,json,jsx,md,ts,tsx,yaml,yml}'"
9+
},
10+
"devDependencies": {
11+
"prettier": "2.5.1"
12+
}
13+
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
prettier@^2.5.1:
6+
version "2.5.1"
7+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
8+
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==

0 commit comments

Comments
 (0)