Skip to content

Commit bf63b10

Browse files
committed
Merge commit '9213f54be532f0cb049da3f202b05558c6eb3001'
2 parents acf9792 + 9213f54 commit bf63b10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3615
-1765
lines changed

.circleci/config.yml

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,86 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: martinthomson/i-d-template:latest
6-
working_directory: ~/draft
5+
- image: cimg/base:stable
6+
auth:
7+
username: $DOCKERHUB_USERNAME
8+
password: $DOCKERHUB_PASSWORD
9+
environment:
10+
# Files that we use to determine whether to build.
11+
DOCKER_BUILD_PATTERN: '^\(docker\|.circleci\)/'
712

813
steps:
914
- checkout
15+
- setup_remote_docker:
16+
version: 20.10.6
1017

1118
- run:
12-
name: "Check Formatting"
19+
name: "Build Docker Image"
1320
command: |
14-
pip3 install --user black==19.3b0 && ln -s $HOME/.local/bin/black $BINDIR
15-
black --check .
21+
if ! git show --name-only --format='' HEAD | grep -q "$DOCKER_BUILD_PATTERN"; then
22+
exit
23+
fi
24+
if [ -n "$CIRCLE_TAG" ]; then
25+
tag="$CIRCLE_TAG"
26+
elif [ "$CIRCLE_BRANCH" = "main" ]; then
27+
tag=latest
28+
else
29+
tag="$CIRCLE_BRANCH"
30+
fi
31+
docker build -t docker.io/martinthomson/i-d-template-action:"$tag" docker/action
32+
docker build -t docker.io/martinthomson/i-d-template:"$tag" \
33+
--build-arg REGISTRY=docker.io --build-arg VERSION="$tag" docker/circleci
1634
1735
- run:
1836
name: "Run Tests"
1937
command: |
20-
if [ -z "$CIRCLE_TAG" ]; then
21-
pip3 install --user behave && ln -s $HOME/.local/bin/behave $BINDIR
22-
mkdir -p /tmp/artifacts
23-
behave --junit --junit-directory /tmp/artifacts tests/*.feature
38+
if [ -n "$CIRCLE_TAG" ]; then
39+
exit
40+
fi
41+
if ! git show --name-only --format='' HEAD | grep -q "$DOCKER_BUILD_PATTERN"; then
42+
tag=latest
43+
elif [ "$CIRCLE_BRANCH" = "main" ]; then
44+
tag=latest
45+
else
46+
tag="$CIRCLE_BRANCH"
47+
fi
48+
set -x
49+
cleanup() { set +e; docker cp test:/tmp/artifacts /tmp/artifacts; docker rm -f test; }
50+
trap cleanup EXIT
51+
docker run -d --name test \
52+
docker.io/martinthomson/i-d-template:"$tag" sleep 300
53+
docker cp . test:/test
54+
docker exec -u 0 test chown -R idci:idci /test
55+
docker exec -u 0 test apk add black
56+
docker exec -w /test test black --check .
57+
docker exec -u 0 test pip3 install --break-system-packages behave
58+
docker exec test mkdir /tmp/artifacts
59+
docker exec -w /test test behave --junit --junit-directory /tmp/artifacts /test/tests
60+
61+
- run:
62+
name: "Push Docker Image"
63+
command: |
64+
if ! git show --name-only --format='' HEAD | grep -q "$DOCKER_BUILD_PATTERN"; then
65+
exit
66+
fi
67+
if [ -n "$CIRCLE_TAG" ]; then
68+
tag="$CIRCLE_TAG"
69+
elif [ "$CIRCLE_BRANCH" = "main" ]; then
70+
tag=latest
71+
else
72+
exit
73+
fi
74+
if [ -n "$DOCKER_PASSWORD" ]; then
75+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
76+
docker push docker.io/martinthomson/i-d-template:"$tag"
2477
fi
2578
2679
- store_artifacts:
2780
path: /tmp/artifacts
2881

82+
- store_test_results:
83+
path: /tmp/artifacts
84+
2985

3086
workflows:
3187
version: 2

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Auto-update GitHub Actions
2+
version: 2
3+
updates:
4+
- package-ecosystem:
5+
- "Bundler"
6+
- "github-actions"
7+
- "pip"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/docker.yml

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,100 @@
11
name: "Update Docker Image for GitHub Action"
22

33
on:
4+
workflow_dispatch:
45
push:
56
paths:
67
- "docker/**"
78
- ".github/workflows/docker.yml"
89
schedule:
910
# Once monthly at a randomly selected time.
10-
- cron: "24 3 18 * *"
11+
- cron: "24 2 3,18 * *"
1112

1213
jobs:
1314
build:
1415
name: "Update Docker Image"
1516
runs-on: ubuntu-latest
17+
18+
services:
19+
registry:
20+
image: registry:2
21+
ports:
22+
- 5000:5000
23+
1624
steps:
1725
- name: "Checkout"
18-
uses: actions/checkout@v2
26+
uses: actions/checkout@v3
1927

20-
- name: "Get Tag"
21-
id: tag
28+
- name: "Configure"
29+
id: config
2230
run: |
2331
ref="${{ github.ref }}"
24-
if [ "$ref" = "refs/heads/master" ]; then
25-
echo "::set-output name=tag::latest"
32+
if [ "$ref" = "refs/heads/main" ]; then
33+
label=latest
2634
elif [ "${ref#refs/tags/}" != "$ref" ]; then
27-
echo "::set-output name=tag::${ref#refs/tags/}"
35+
label="${ref#refs/tags/}"
36+
else
37+
label=test
38+
fi
39+
tag() {
40+
echo "${1}/martinthomson/i-d-template${2}:${label}"
41+
}
42+
if [ "$label" = "test" ]; then
43+
registry=localhost:5000
44+
driver_opts="network=host"
2845
else
29-
echo "::set-output name=tag::"
46+
registry=ghcr.io
47+
driver_opts=
3048
fi
49+
action_tags="$(tag "$registry" -action)"
50+
circle_tags="$(tag "$registry" "")"
51+
math_tags="$(tag "$registry" -math)"
52+
echo "registry=$registry" >>"$GITHUB_OUTPUT"
53+
echo "driver_opts=$driver_opts" >>"$GITHUB_OUTPUT"
54+
echo "label=$label" >>"$GITHUB_OUTPUT"
55+
echo "action_tags=$action_tags" >>"$GITHUB_OUTPUT"
56+
echo "circle_tags=$circle_tags" >>"$GITHUB_OUTPUT"
57+
echo "math_tags=$math_tags" >>"$GITHUB_OUTPUT"
58+
59+
- name: "Setup Docker Buildx"
60+
uses: docker/setup-buildx-action@v2
61+
with:
62+
driver-opts: ${{ steps.config.outputs.driver_opts }}
63+
64+
- name: "Login to GitHub Container Registry"
65+
if: ${{ steps.config.outputs.label != 'test' }}
66+
uses: docker/login-action@v2
67+
with:
68+
registry: ghcr.io
69+
username: ${{ secrets.GHCR_USERNAME }}
70+
password: ${{ secrets.GHCR_PASSWORD }}
71+
72+
- name: "Build and Publish GitHub Actions Image"
73+
uses: docker/build-push-action@v3
74+
with:
75+
context: ./docker/action
76+
file: ./docker/action/Dockerfile
77+
push: true
78+
tags: ${{ steps.config.outputs.action_tags }}
79+
80+
- name: "Build and Publish CircleCI Image"
81+
uses: docker/build-push-action@v3
82+
with:
83+
context: ./docker/circleci
84+
file: ./docker/circleci/Dockerfile
85+
build-args: |
86+
REGISTRY=${{ steps.config.outputs.registry }}
87+
VERSION=${{ steps.config.outputs.label }}
88+
push: true
89+
tags: ${{ steps.config.outputs.circle_tags }}
3190

32-
- name: "Publish to Dockerhub"
33-
uses: docker/build-push-action@v1
91+
- name: "Build and Publish Math Image"
92+
uses: docker/build-push-action@v3
3493
with:
35-
username: ${{ secrets.DOCKER_USERNAME }}
36-
password: ${{ secrets.DOCKER_PASSWORD }}
37-
repository: martinthomson/i-d-template-action
38-
path: action
39-
tags: ${{ steps.tag.outputs.tag }}
40-
push: ${{ steps.tag.outputs.tag != '' }}
94+
context: ./docker/math
95+
file: ./docker/math/Dockerfile
96+
build-args: |
97+
REGISTRY=${{ steps.config.outputs.registry }}
98+
VERSION=${{ steps.config.outputs.label }}
99+
push: true
100+
tags: ${{ steps.config.outputs.math_tags }}

.github/workflows/template.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Validate Workflows in Template"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- ".github/workflows/template.yml"
8+
- "template/.github/workflows/**"
9+
- "v3.css"
10+
- "Gemfile"
11+
- "action/docker/Gemfile"
12+
- "requirements.txt"
13+
- "action/docker/requirements.txt"
14+
15+
16+
jobs:
17+
build:
18+
name: "Validate Workflows"
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: "Checkout"
23+
uses: actions/checkout@v3
24+
25+
- name: "Verify Gemfile and requirements.txt consistency"
26+
run: |
27+
e=''
28+
for src in Gemfile requirements.txt; do
29+
dst="docker/action/$src"
30+
[ -f "$src" ] || e="$e\n$src is missing"
31+
[ -f "$dst" ] || e="$e\n$dst is missing"
32+
diff -u "$dst" "$src" || e="$e\n$src and $dst differ"
33+
done
34+
if [ -n "$e" ]; then
35+
! printf "$e"
36+
fi
37+
38+
- name: "Compare workflow files in internet-draft-template"
39+
run: |
40+
git clone --depth 1 https://github.com/martinthomson/internet-draft-template idt
41+
e=''
42+
for src in template/.github/workflows/*.yml; do
43+
dst="idt/${src#*/}"
44+
[ -f "$dst" ] || e="$e\nworkflow ${src##*/} is missing from internet-draft-template"
45+
diff -u "$dst" "$src" || e="$e\nworkflow ${src##*/} differs"
46+
done
47+
if [ -n "$e" ]; then
48+
! printf "$e"
49+
fi
50+
51+
- name: "Compare CSS in rfc-css"
52+
run: |
53+
git clone --depth 1 https://github.com/martinthomson/rfc-css rfc-css
54+
diff -u <(./rfc-css/combine.sh) v3.css || ! echo "v3.css differs from rfc-css"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ draft-*
2828
issues.json
2929
pulls.json
3030
*.DS_Store
31+
*.DS_Store
32+
Gemfile.lock
33+
.gems
34+
.venv

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'kramdown-rfc'
4+
gem 'net-http-persistent'

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ inputs:
66
make:
77
description: 'The make target to build'
88
required: false
9-
default: 'latest'
9+
default: 'all'
10+
11+
token:
12+
description: 'Set this to secrets.GITHUB_TOKEN'
13+
required: false
1014

1115
runs:
1216
using: 'docker'
13-
image: 'docker://martinthomson/i-d-template-action:latest'
17+
image: 'docker://ghcr.io/martinthomson/i-d-template-action:latest'
1418
args:
1519
- ${{ inputs.make }}
20+
env:
21+
GITHUB_TOKEN: ${{ inputs.token }}
1622

1723
branding:
1824
icon: 'check-square'

archive.mk

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,27 @@ ifeq (,$(GITHUB_API_TOKEN))
1818
DISABLE_ARCHIVE_FETCH := true
1919
endif
2020

21+
archive_script = $(trace) archive -s archive-repo \
22+
$(python) -m archive-repo archive $(GITHUB_REPO_FULL) $(GITHUB_API_TOKEN)
23+
ifeq (true,$(ARCHIVE_FULL))
24+
define archive_issues
25+
echo $(archive_script) $(1); \
26+
$(archive_script) $(1)
27+
endef
28+
else
29+
define archive_issues
30+
old_archive=$$(mktemp $(TMPDIR)/tmp/archive-old.XXXXXX); \
31+
trap 'rm -f $$old_archive' EXIT; \
32+
git show $(ARCHIVE_BRANCH):$(1) > $$old_archive || true; \
33+
echo $(archive_script) $(1) --reference $$old_archive; \
34+
$(archive_script) $(1) --reference $$old_archive
35+
endef
36+
endif
37+
2138
## Store a copy of any GitHub issues and pull requests.
2239
.PHONY: archive
2340
archive: archive.json
24-
archive.json: fetch-archive $(drafts_source)
41+
archive.json: fetch-archive $(drafts_source) $(DEPS_FILES)
2542
@if [ -f $@ ] && [ "$(call file_size,$@)" -gt 0 ] && \
2643
[ "$(call last_modified,$@)" -gt "$(call last_commit,$(ARCHIVE_BRANCH),$@)" ] 2>/dev/null; then \
2744
echo 'Skipping update of $@ (it is newer than the ones on the branch)'; exit; \
@@ -36,13 +53,9 @@ archive.json: fetch-archive $(drafts_source)
3653
git show $(ARCHIVE_BRANCH):$@ > $@ || true; \
3754
exit; \
3855
fi; \
39-
old_archive=$$(mktemp /tmp/archive-old.XXXXXX); \
40-
trap 'rm -f $$old_archive' EXIT; \
41-
git show $(ARCHIVE_BRANCH):$@ > $$old_archive || true; \
42-
$(LIBDIR)/archive_repo.py $(GITHUB_REPO_FULL) $(GITHUB_API_TOKEN) $@ --reference $$old_archive;
43-
56+
$(call archive_issues,$@)
4457

45-
ARCHIVE_ROOT := /tmp/gharchive$(shell echo $$$$)
58+
ARCHIVE_ROOT := $(TMPDIR)/gharchive$(PID)
4659
$(ARCHIVE_ROOT): fetch-archive
4760
@git show-ref refs/heads/$(ARCHIVE_BRANCH) >/dev/null 2>&1 || \
4861
(git show-ref refs/remotes/origin/$(ARCHIVE_BRANCH) >/dev/null 2>&1 && \
@@ -55,6 +68,10 @@ $(ARCHIVE_ROOT)/%.json: %.json $(ARCHIVE_ROOT)
5568

5669
## Commit and push the changes to $(ARCHIVE_BRANCH)
5770
.PHONY: gh-archive
71+
ifneq (,$(MAKE_TRACE))
72+
gh-archive:
73+
@$(call MAKE_TRACE,gh-archive)
74+
else
5875
gh-archive: $(ARCHIVE_ROOT)/archive.json
5976
cp -f $(LIBDIR)/template/issues.html $(LIBDIR)/template/issues.js $(ARCHIVE_ROOT)
6077
@-git -C $(ARCHIVE_ROOT) rm --ignore-unmatch -f issues.json pulls.json
@@ -63,15 +80,21 @@ gh-archive: $(ARCHIVE_ROOT)/archive.json
6380
git -C $(ARCHIVE_ROOT) $(CI_AUTHOR) commit -m "Script updating archive at $(shell date -u +%FT%TZ). [ci skip]"; fi
6481
ifeq (true,$(PUSH_GHPAGES))
6582
ifneq (,$(if $(CI_HAS_WRITE_KEY),1,$(if $(GITHUB_PUSH_TOKEN),,1)))
66-
git -C $(ARCHIVE_ROOT) push -f https://github.com/$(GITHUB_REPO_FULL) $(ARCHIVE_BRANCH)
83+
$(trace) archive -s archive-push git -C $(ARCHIVE_ROOT) push -f "$(shell git remote get-url --push $(GIT_REMOTE))" $(ARCHIVE_BRANCH)
6784
else
6885
@echo git -C $(ARCHIVE_ROOT) push -qf https://github.com/$(GITHUB_REPO_FULL) $(ARCHIVE_BRANCH)
69-
@git -C $(ARCHIVE_ROOT) push -qf https://$(GITHUB_PUSH_TOKEN)@github.com/$(GITHUB_REPO_FULL) $(ARCHIVE_BRANCH) >/dev/null 2>&1
86+
@git -C $(ARCHIVE_ROOT) push -qf https://$(GITHUB_PUSH_TOKEN)@github.com/$(GITHUB_REPO_FULL) $(ARCHIVE_BRANCH) >/dev/null 2>&1 \
87+
|| $(trace) all -s archive-push ! echo "git -C $(GHPAGES_ROOT) push -qf https://****@github.com/$(GITHUB_REPO_FULL) $(ARCHIVE_BRANCH)"
7088
endif
7189
else
72-
git -C $(ARCHIVE_ROOT) push -f origin $(ARCHIVE_BRANCH)
90+
ifeq (true,$(CI))
91+
@echo "*** Warning: pushing to the gh-pages branch is disabled."
92+
else
93+
$(trace) all -s archive-push git -C $(ARCHIVE_ROOT) push -f origin $(ARCHIVE_BRANCH)
94+
endif
7395
endif # PUSH_GHPAGES
7496
-rm -rf $(ARCHIVE_ROOT)
97+
endif # MAKE_TRACE
7598

7699
## Save archive.json to the CI_ARTIFACTS directory
77100
ifneq (,$(CI_ARTIFACTS))

0 commit comments

Comments
 (0)