From c56cfeda20a843a60198efbe5c969357f94e3ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Thu, 11 Jun 2020 15:21:47 +0200 Subject: [PATCH 1/2] Add GitHub Actions deploy.yml template Also remove any files that are part of the Travis setup. Part of https://github.com/whatwg/meta/issues/173. --- .github/workflows/deploy.yml.template | 17 +++++++++++++ .gitignore.template | 2 -- factory.py | 35 ++++++++++++++++++--------- 3 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/deploy.yml.template diff --git a/.github/workflows/deploy.yml.template b/.github/workflows/deploy.yml.template new file mode 100644 index 0000000..8b996d5 --- /dev/null +++ b/.github/workflows/deploy.yml.template @@ -0,0 +1,17 @@ +name: deploy +on: + push: + branches: + - master +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - run: make deploy + env: + SERVER: ${{ secrets.MARQUEE_SERVER }} + SERVER_PUBLIC_KEY: ${{ secrets.MARQUEE_PUBLIC_KEY }} + SERVER_DEPLOY_KEY: ${{ secrets.MARQUEE_DEPLOY_KEY }} diff --git a/.gitignore.template b/.gitignore.template index 36c0f96..631a839 100644 --- a/.gitignore.template +++ b/.gitignore.template @@ -1,6 +1,4 @@ /@@shortname@@.spec.whatwg.org/ /deploy.sh -/deploy_key -/deploy_key.pub /@@bs@@.html /review.sh@@.gitignore@@ diff --git a/factory.py b/factory.py index 0ad57de..e8c3feb 100755 --- a/factory.py +++ b/factory.py @@ -1,28 +1,37 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 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 @@ -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 @@ -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) From 74e719cc0904d357cb73c254f2fca82869e33a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Thu, 11 Jun 2020 17:04:39 +0200 Subject: [PATCH 2/2] Install specific versions of python and node --- .../{deploy.yml.template => build.yml.template} | 16 +++++++++++++--- factory.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) rename .github/workflows/{deploy.yml.template => build.yml.template} (54%) diff --git a/.github/workflows/deploy.yml.template b/.github/workflows/build.yml.template similarity index 54% rename from .github/workflows/deploy.yml.template rename to .github/workflows/build.yml.template index 8b996d5..68c142f 100644 --- a/.github/workflows/deploy.yml.template +++ b/.github/workflows/build.yml.template @@ -1,15 +1,25 @@ -name: deploy +name: build on: + pull_request: + branches: + - master push: branches: - - master + - master jobs: - deploy: + 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 }} diff --git a/factory.py b/factory.py index e8c3feb..6dfda89 100755 --- a/factory.py +++ b/factory.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python import os, subprocess, uuid, json, requests