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

Check Echidna publishing results for failure or success #1821

Merged
merged 20 commits into from
Oct 4, 2024
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
19 changes: 15 additions & 4 deletions .github/workflows/w3c-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Publish to W3C TR space
name: Validate/Publish to W3C TR space

on:
push:
branches: [ main ]
paths: [ .github/**, document/** ]
pull_request:
paths: [ .github/**, document/** ]

# Allows you to run this workflow manually from the Actions tab, gh CLI tool,
# or REST API. THe w3c-status options correspond to the valid options for
Expand All @@ -23,9 +25,12 @@ on:
- CRD
- CR

env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
W3C_STATUS: ${{ github.event_name == 'workflow_dispatch' && inputs.w3c-status || 'WD' }}

jobs:
publish-to-w3c-TR:
if: github.repository == 'WebAssembly/spec'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -43,10 +48,16 @@ jobs:
- name: Setup Sphinx
run: pip install six && pip install sphinx==5.1.0
- name: Publish all specs to their https://www.w3.org/TR/ URLs
if: env.W3C_ECHIDNA_TOKEN_CORE
run: cd document && make -e WD-echidna-CI
env:
W3C_STATUS: ${{ github.event_name == 'push' && 'WD' || inputs.w3c-status }}
W3C_ECHIDNA_TOKEN_CORE: ${{ secrets.W3C_ECHIDNA_TOKEN_CORE }}
W3C_ECHIDNA_TOKEN_JSAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_JSAPI }}
W3C_ECHIDNA_TOKEN_WEBAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_WEBAPI }}
YARN_ENABLE_IMMUTABLE_INSTALLS: false
ECHIDNA_DRYRUN: ${{ !(github.event_name == 'push' && github.repository == 'WebAssembly/spec' && github.ref == 'refs/heads/main') }}
- name: Validate all specs with Echidna
if: env.W3C_USERNAME
run: cd document && make -e WD-echidna
env:
W3C_USERNAME: ${{ secrets.W3C_USERNAME }}
W3C_PASSWORD: ${{ secrets.W3C_PASSWORD }}
9 changes: 7 additions & 2 deletions document/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ NAME = WebAssembly
DECISION_URL = https://github.com/WebAssembly/meetings/blob/main/main/2024/WG-06-12.md
TAR = tar
DEADLINE = $(shell date -d "+30 days" +%Y-%m-%d 2>/dev/null || date -v +30d +%Y-%m-%d)
ECHIDNA_DRYRUN = true

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
Expand Down Expand Up @@ -196,7 +197,9 @@ WD-echidna: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
--user '$(W3C_USERNAME):$(W3C_PASSWORD)' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"

Expand All @@ -210,7 +213,9 @@ WD-echidna-CI: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "token=$(W3C_ECHIDNA_TOKEN_CORE)" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"

Expand Down
11 changes: 9 additions & 2 deletions document/js-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ NAME = WebAssembly
DECISION_URL = https://github.com/WebAssembly/meetings/blob/main/main/2024/WG-06-12.md
TAR = tar
DEADLINE = $(shell date -d "+30 days" +%Y-%m-%d 2>/dev/null || date -v +30d +%Y-%m-%d)
ECHIDNA_DRYRUN = true

.PHONY: all
all:
Expand Down Expand Up @@ -50,7 +51,11 @@ WD-echidna: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
--user '$(W3C_USERNAME):$(W3C_PASSWORD)' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
dschuff marked this conversation as resolved.
Show resolved Hide resolved
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"

.PHONY: WD-echidna-CI
WD-echidna-CI: WD-tar
Expand All @@ -62,6 +67,8 @@ WD-echidna-CI: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "token=$(W3C_ECHIDNA_TOKEN_JSAPI)" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
58 changes: 58 additions & 0 deletions document/util/check-echidna-status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

from datetime import datetime, timedelta
import json
import os
import requests
import sys
import time

ECHIDNA_ID_FILE = 'WD-echidna-id.txt'
ECHIDNA_STATUS_URL = 'http://labs.w3.org/echidna/api/status?id='


def get_echidna_id(directory):
id_file = os.path.join(directory, ECHIDNA_ID_FILE)
file_time = os.path.getmtime(id_file)
if datetime.fromtimestamp(file_time) < datetime.now() - timedelta(hours=1):
print(f'Warning: Echidna ID is not recent: timestamp is {file_time}')
with open(id_file, 'r') as f:
return f.read().strip()


def get_current_response(echidna_id):
url = ECHIDNA_STATUS_URL + echidna_id
print(f'Fetching {url}')
response = requests.get(url, allow_redirects=True)
if response.status_code != 200:
print(f'Got status code {response.status_code}, text:')
print(response.text)
raise Exception('Failed to fetch echidna result')

return response.json()


def get_echidna_result(echidna_id):
response = get_current_response(echidna_id)
while response['results']['status'] == 'started':
time.sleep(5)
print('Echidna run in progress, retrying...')
response = get_current_response(echidna_id)

result = response['results']['status']
print(f'Echidna issue {echidna_id} is {result}.')
print(json.dumps(response, indent=2))
return result == 'success'


def main(argv):
directory = os.getcwd() if len(argv) < 2 else argv[1]
echidna_id = get_echidna_id(directory)
print(f'Got echidna id {echidna_id}.')
time.sleep(5)
if not get_echidna_result(echidna_id):
sys.exit(1)


if __name__ == '__main__':
main(sys.argv)
11 changes: 9 additions & 2 deletions document/web-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ NAME = WebAssembly
DECISION_URL = https://github.com/WebAssembly/meetings/blob/main/main/2024/WG-06-12.md
TAR = tar
DEADLINE = $(shell date -d "+30 days" +%Y-%m-%d 2>/dev/null || date -v +30d +%Y-%m-%d)
ECHIDNA_DRYRUN = true

.PHONY: all
all:
Expand Down Expand Up @@ -50,7 +51,11 @@ WD-echidna: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
--user '$(W3C_USERNAME):$(W3C_PASSWORD)' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
dschuff marked this conversation as resolved.
Show resolved Hide resolved
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"

.PHONY: WD-echidna-CI
WD-echidna-CI: WD-tar
Expand All @@ -62,6 +67,8 @@ WD-echidna-CI: WD-tar
curl 'https://labs.w3.org/echidna/api/request' \
-F "tar=@$(BUILDDIR)/WD.tar" \
-F "token=$(W3C_ECHIDNA_TOKEN_WEBAPI)" \
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
-F "decision=$(DECISION_URL)" \
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
python3 ../util/check-echidna-status.py $(BUILDDIR)
@echo
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
Loading