diff --git a/proposal-template/README.md b/proposal-template/README.md new file mode 100644 index 00000000..b9703593 --- /dev/null +++ b/proposal-template/README.md @@ -0,0 +1,4 @@ +# Proposal template + +This directory will hold a template for creating new proposals, to help people +get started. diff --git a/proposals/README.md b/proposals/README.md new file mode 100644 index 00000000..45c2c285 --- /dev/null +++ b/proposals/README.md @@ -0,0 +1,8 @@ +# Proposals + +This directory contains overviews for proposals that are included in this +repository. + +This is analogous to [the correpsonding directory in the spec repository]. + +[the correpsonding directory in the spec repository]: https://github.com/WebAssembly/spec/tree/master/proposals diff --git a/repos/README.md b/repos/README.md new file mode 100644 index 00000000..c628b3f0 --- /dev/null +++ b/repos/README.md @@ -0,0 +1,7 @@ +The spec and proposal repositories will be cloned in this directory by the +make-testsuite.sh script. Don't apply local changes to these repositories, as +the script may destroy them. + +This is analogous to [the coresponding wasm testsuite directory]. + +[the coresponding wasm testsuite directory]: https://github.com/WebAssembly/testsuite/tree/master/repos diff --git a/snapshots/README.md b/snapshots/README.md new file mode 100644 index 00000000..af94dbde --- /dev/null +++ b/snapshots/README.md @@ -0,0 +1,5 @@ +# WASI Snapshots + +To balance between the needs of development and stability, snapshots +represent the state of all active proposals at a moment in time. Individual +Snapshots are stable, but WASI as a whole is evolving. diff --git a/snapshots/make-snapshot.sh b/snapshots/make-snapshot.sh new file mode 100755 index 00000000..b7c177f2 --- /dev/null +++ b/snapshots/make-snapshot.sh @@ -0,0 +1,159 @@ +#!/bin/bash +# Creates a snapshot based on upstream proposal repositories. +# Derived from update-testsuite.sh in https://github.com/WebAssembly/testsuite +set -e +set -u +set -o pipefail + +ignore_dirs='' + +# TODO: Add the rest. +repos=' + WASI + wasi-filesystem + wasi-clocks + wasi-random +' + +log_and_run() { + echo ">>" $* + if ! $*; then + echo "sub-command failed: $*" + exit + fi +} + +try_log_and_run() { + echo ">>" $* + $* +} + +pushdir() { + pushd $1 >/dev/null || exit +} + +popdir() { + popd >/dev/null || exit +} + +update_repo() { + local repo=$1 + pushdir repos + if [ -d ${repo} ]; then + log_and_run git -C ${repo} fetch origin + log_and_run git -C ${repo} reset origin/master --hard + else + log_and_run git clone https://github.com/WebAssembly/${repo} + fi + + # Add upstream WASI as "WASI" remote. + if [ "${repo}" != "WASI" ]; then + pushdir ${repo} + if ! git remote | grep WASI >/dev/null; then + log_and_run git remote add WASI https://github.com/WebAssembly/WASI + fi + + log_and_run git fetch WASI + popdir + fi + popdir +} + +merge_with_WASI() { + local repo=$1 + + [ "${repo}" == "WASI" ] && return + + pushdir repos/${repo} + # Create and checkout "try-merge" branch. + if ! git branch | grep try-merge >/dev/null; then + log_and_run git branch try-merge origin/master + fi + log_and_run git checkout try-merge + + # Attempt to merge with WASI/master. + log_and_run git reset origin/master --hard + try_log_and_run git merge -q WASI/master -m "merged" + if [ $? -ne 0 ]; then + # Ignore merge conflicts in non-test directories. + # We don't care about those changes. + try_log_and_run git checkout --ours ${ignore_dirs} + try_log_and_run git add ${ignore_dirs} + try_log_and_run git -c core.editor=true merge --continue + if [ $? -ne 0 ]; then + git merge --abort + popdir + return 1 + fi + fi + popdir + return 0 +} + +snapshot_name=$(date --iso-8601) +snapshot_dir=snapshots/$snapshot_name +mkdir -p $snapshot_dir + +commit_message_file=$PWD/commit_message +echo -e "Update repos\n" > $commit_message_file + +failed_repos= + +for repo in ${repos}; do + echo "++ updating ${repo}" + update_repo ${repo} + + if ! merge_with_WASI ${repo}; then + echo -e "!! error merging ${repo}, skipping\n" + failed_repos="${failed_repos} ${repo}" + continue + fi + + if [ "${repo}" = "WASI" ]; then + dest_dir=$snapshot_dir + log_and_run cp -r repos/${repo}/standard ${dest_dir} + else + dest_dir=$snapshot_dir/proposals/${repo} + mkdir -p ${dest_dir} + + # Don't add tests from proposal that are the same as WASI. + pushdir repos/${repo} + for new in $(find standard -type f); do + old=../../repos/WASI/${new} + if [[ ! -f ${old} ]] || ! diff ${old} ${new} >/dev/null; then + log_and_run cp ${new} ../../${dest_dir} + fi + done + popdir + fi + + # Check whether any files were removed. + for old in $(find ${dest_dir} -type f); do + new=$(find repos/${repo}/standard -name ${old##*/}) + if [[ ! -f ${new} ]]; then + log_and_run git rm ${old} + fi + done + + # Check whether any files were updated. + if [ $(git status -s ${dest_dir} | wc -l) -ne 0 ]; then + log_and_run git add ${dest_dir}/* + + repo_sha=$(git -C repos/${repo} log --max-count=1 --oneline origin/master| sed -e 's/ .*//') + echo " ${repo}:" >> $commit_message_file + echo " https://github.com/WebAssembly/${repo}/commit/${repo_sha}" >> $commit_message_file + fi + + echo -e "-- ${repo}\n" +done + +echo "" >> $commit_message_file +echo "This change was automatically generated by \`make-snapshot.sh\`" >> $commit_message_file +git commit -a -F $commit_message_file +# git push + +echo "done" + +if [ -n "${failed_repos}" ]; then + echo "!! failed to update repos: ${failed_repos}" +fi diff --git a/standard/README.md b/standard/README.md new file mode 100644 index 00000000..ad6f93c7 --- /dev/null +++ b/standard/README.md @@ -0,0 +1,12 @@ +# WASI Standard + +In the [main WASI repository], this directory holds proposals which have +[completed the standardization process]. + +In a proposal repository, which is a fork of the main WASI repository, +this directory holds the current proposal, including witx specifications, +tests, and documentation. When the proposal is standardized, the fork is +merged into the main repository. + +[main WASI repository]: https://github.com/WebAssembly/WASI/issues/360 +[completed the standardization process]: https://github.com/WebAssembly/meetings/blob/master/process/phases.md#5-the-feature-is-standardized-working-group