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

Add GitHub Actions build.yml template #14

Merged
merged 2 commits into from
Jun 12, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/setup-node@v1
with:
node-version: 14
# Note: `make deploy` will do a deploy dry run on PRs.
- run: make deploy
env:
SERVER: ${{ secrets.MARQUEE_SERVER }}
SERVER_PUBLIC_KEY: ${{ secrets.MARQUEE_PUBLIC_KEY }}
SERVER_DEPLOY_KEY: ${{ secrets.MARQUEE_DEPLOY_KEY }}
2 changes: 0 additions & 2 deletions .gitignore.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/@@shortname@@.spec.whatwg.org/
/deploy.sh
/deploy_key
/deploy_key.pub
/@@bs@@.html
/review.sh@@.gitignore@@
33 changes: 23 additions & 10 deletions factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,36 @@

import os, subprocess, uuid, json, requests

OBSOLETE_FILES = [".travis.yml", "deploy_key.enc"]

def read_file(file):
return open(file, "r", encoding="utf-8").read()

def write_file(file, contents):
dirs = os.path.dirname(file)
if dirs:
os.makedirs(dirs, exist_ok=True)
open(file, "w", encoding="utf-8").write(contents)

def href_to_shortname(href):
return href[len("https://"):href.index(".")]

def find_files_with_extension(extension):
files = []
for file in os.listdir("."):
if os.path.isfile(file) and file.endswith(extension):
files.append(file)
return files
def find_files_with_extension(extension, recurse=True):
paths = []
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(extension):
path = os.path.relpath(os.path.join(root, file), start=".")
paths.append(path)
if not recurse:
del dirs[:]
return paths


def gather_templates():
templates = {}
for file in find_files_with_extension(".template"):
templates[file] = read_file(file)
for path in find_files_with_extension(".template"):
templates[path] = read_file(path)
return templates


Expand Down Expand Up @@ -55,7 +64,7 @@ def update(templates, variables):

# HTML does not use Bikeshed (yet). We do want some output for comparison purposes
if variables["shortname"] != "html":
[bs_file] = find_files_with_extension(".bs")
[bs_file] = find_files_with_extension(".bs", recurse=False)
bs = bs_file[:-len(".bs")]
variables["bs"] = bs

Expand All @@ -69,7 +78,11 @@ def update(templates, variables):
elif variables["not_these_templates"] and file in variables["not_these_templates"]:
continue
write_file(file, files[file])
subprocess.run(["git", "add", file], capture_output=True)
for file in OBSOLETE_FILES:
if os.path.isfile(file):
os.remove(file)

subprocess.run(["git", "add", "-A"], capture_output=True)
if b"Changes to be committed" in subprocess.run(["git", "status"], capture_output=True).stdout:
subprocess.run(["git", "checkout", "-b", "meta-template/{}".format(uuid.uuid1())], capture_output=True)
subprocess.run(["git", "commit", "-m", "Meta: update repository files\n\nSee https://github.com/whatwg/spec-factory for details."], capture_output=True)
Expand Down