diff --git a/.circleci/PR_base b/.circleci/PR_base index 2907f5fdd..93be745d2 100755 --- a/.circleci/PR_base +++ b/.circleci/PR_base @@ -11,14 +11,13 @@ ## ## License: GPLv3 -skip_when_branch_update fail_when_undefined_pr_number pr_base=$(curl -s "${pr_data_URL}" | jq '.base.ref') -if [[ "${pr_base}" == "\"${dev_b}\"" ]]; then +if [[ "${pr_base}" == "\"develop\"" ]]; then echo "You are PRing to the develop branch. This is good." exit 0 -elif [[ "${pr_base}" == "\"${mst_b}\"" ]]; then +elif [[ "${pr_base}" == "\"master\"" ]]; then printf '=%.0s' {1..80} printf "\n し(*・∀・)/ Thanks for the contribution! \(・∀・*)ノ\n" printf '=%.0s' {1..80} diff --git a/.circleci/PR_rebased b/.circleci/PR_rebased index 0d0170d2c..5380ac8ad 100755 --- a/.circleci/PR_rebased +++ b/.circleci/PR_rebased @@ -11,7 +11,6 @@ ## ## License: GPLv3 -skip_when_branch_update fail_when_undefined_pr_number upstream_head_sha=$(curl -s "${upstream_data_URL}" | jq '.commit.sha') diff --git a/.circleci/apply_patch b/.circleci/apply_patch new file mode 100755 index 000000000..1df6d2c91 --- /dev/null +++ b/.circleci/apply_patch @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +## apply_patch Apply patch to the target(official spacemacs) repository +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +if [ ! -f "/tmp/${PUBLISH}.patch" ]; then + echo "No /tmp/${PUBLISH}.patch file. Aborting." + exit 0 +else + echo_headline "Cloning target repository" + target_URL="https://github.com/${prj_owner}/${prj_repo}.git" + git clone "${target_URL}" -b "${CIRCLE_BRANCH}" "/tmp/${PUBLISH}" + if [ $? -ne 0 ]; then + echo "Failed to clone \"${target_URL}\"" + exit 2 + fi + + cd "/tmp/${PUBLISH}" + + echo_headline "Patching" + git am < /tmp/spacemacs.patch + if [ $? -ne 0 ]; then + echo "Failed to apply /tmp/${PUBLISH}.patch." + exit 2 + fi +fi diff --git a/.circleci/bot_init b/.circleci/bot_init index 970ed5c2d..1e315efcb 100755 --- a/.circleci/bot_init +++ b/.circleci/bot_init @@ -11,8 +11,6 @@ ## ## License: GPLv3 -skip_when_non_official_repo - echo_headline "Setting up bot account" mkdir -p ~/.ssh diff --git a/.circleci/built_in/make_patch b/.circleci/built_in/make_patch new file mode 100755 index 000000000..16f29960f --- /dev/null +++ b/.circleci/built_in/make_patch @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +## make_patch Creates patch file with updates of built-in Spacemacs files. +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +git add --all +git commit -m "Built-in files auto-update: $(date -u)" +if [ $? -ne 0 ]; then + echo "Built-in files don't need an update." + exit 0 +else + git format-patch -1 HEAD --stdout > "/tmp/${PUBLISH}.patch" + if [ $? -ne 0 ]; then + echo "Failed to create built-in patch file." + exit 2 + fi + git reset --hard HEAD~1 + cat "/tmp/${PUBLISH}.patch" +fi diff --git a/.circleci/built_in/maybe_pr b/.circleci/built_in/maybe_pr new file mode 100755 index 000000000..7dd7345ec --- /dev/null +++ b/.circleci/built_in/maybe_pr @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +## open_pr Opens PR to Spacemacs repository with built-in updates +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +echo_headline "Opening PR to ${UPD_BOT_LOGIN}/${UPD_BOT_REPO} repo" +echo "[bot] Built-in auto-update" > msg +echo >> msg +echo "Merge with care - I'm just a stupid bot. Beep boop." >> msg +hub pull-request -h "${PUBLISH}" -b "${CIRCLE_BRANCH}" -F msg +if [ $? -ne 0 ]; then + echo "Seems like PR already exists (not a problem)" +fi diff --git a/.circleci/update/upd_built_in b/.circleci/built_in/upd_built_in similarity index 65% rename from .circleci/update/upd_built_in rename to .circleci/built_in/upd_built_in index 9476804f5..a2e6043a5 100755 --- a/.circleci/update/upd_built_in +++ b/.circleci/built_in/upd_built_in @@ -10,8 +10,6 @@ ## ## License: GPLv3 -skip_when_non_official_repo - echo_headline "Downloading and replacing files" built_in_manifest=".ci/built_in_manifest" lines=$(cat "${built_in_manifest}") @@ -25,18 +23,3 @@ while read line; do exit 2 fi done <"${built_in_manifest}" - -git add --all -git commit -m "Built-in files auto-update: $(date -u)" -if [ $? -ne 0 ]; then - echo "Built-in files don't need an update." - exit 0 -else - git format-patch -1 HEAD --stdout > /tmp/built_in.patch - if [ $? -ne 0 ]; then - echo "Failed to create built-in patch file." - exit 2 - fi - git reset --hard HEAD~1 - cat /tmp/built_in.patch -fi diff --git a/.circleci/config.yml b/.circleci/config.yml index 845613d78..61174f537 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,70 +1,23 @@ ---- -# Circle CI YAML file -version: 2.0 - +#### Config generator for CircleCI. +version: 2.1 +setup: true +orbs: + continuation: circleci/continuation@0.1.0 jobs: - "Validate PR": - docker: - - image: jare/spacemacs-circleci:latest - environment: - BASH_ENV: ".circleci/shared" + "Generate config": + executor: continuation/default steps: - checkout - - run: - name: Make sure that this PR targets develop branch - command: .circleci/PR_base - - run: - name: Make sure that this PR doesn't need rebase - command: .circleci/PR_rebased - "Validate Documentation": - docker: - - image: jare/spacemacs-circleci:latest - environment: - BASH_ENV: ".circleci/shared" - steps: - - checkout - - run: - name: Select changed files - command: .circleci/select_pr_changed - - run: - name: export changed documentation files for validation - command: .circleci/org/export - - run: - name: validating changed documentation files - command: .circleci/org/validate - "Update built-in files": - docker: - - image: jare/spacemacs-circleci:latest - environment: - - BASH_ENV: ".circleci/shared" - - PUBLISH: "spacemacs_built_in" - - UPD_BOT_LOGIN: "SpacemacsBot" - - UPD_BOT_REPO: "spacemacs" - steps: - - checkout - - run: - name: Initialize bot account - command: .circleci/bot_init - - run: - name: Make patch file - command: .circleci/update/upd_built_in - - run: - name: Open PR if built in files must be updated - command: .circleci/update/maybe_pr - + - run: + name: "Render config_tmpl.yml" + command: | + cd .circleci/ + cp config_tmpl.yml circleci.yml + sed -i "s/{{ IS_BRANCH_UDATE }}/${IS_BRANCH_UPDATE}/g" circleci.yml + - continuation/continue: + parameters: '{}' + configuration_path: ".circleci/circleci.yml" workflows: - version: 2 - validate_pr_files: + setup-workflow: jobs: - - "Validate PR" - - "Validate Documentation" - update_built_in: - triggers: - - schedule: - cron: "0 0,6,12,18 * * *" - filters: - branches: - only: - - develop - jobs: - - "Update built-in files" + - "Generate config" diff --git a/.circleci/config_tmpl.yml b/.circleci/config_tmpl.yml new file mode 100644 index 000000000..936fcd191 --- /dev/null +++ b/.circleci/config_tmpl.yml @@ -0,0 +1,141 @@ +#### Circle CI YAML file +version: 2.1 +parameters: + prj_owner: + type: string + default: "syl20bnr" + prj_repo: + type: string + default: "spacemacs" + prj_url: + type: string + default: "https://github.com/syl20bnr/spacemacs" + is_branch_update: + type: string + default: "{{ IS_BRANCH_UDATE }}" + +jobs: + "Validate PR": + docker: + - image: jare/spacemacs-circleci:latest + environment: + - PRJ_OWNER: << pipeline.parameters.prj_owner >> + - PRJ_REPO: << pipeline.parameters.prj_repo >> + - BASH_ENV: ".circleci/shared" + working_directory: ~/.emacs.d + steps: + - checkout + - run: + name: Make sure that this PR targets develop branch + command: .circleci/PR_base + - run: + name: Make sure that this PR doesn't need rebase + command: .circleci/PR_rebased + "Validate Documentation": + docker: + - image: jare/spacemacs-circleci:latest + environment: + - PRJ_OWNER: << pipeline.parameters.prj_owner >> + - PRJ_REPO: << pipeline.parameters.prj_repo >> + - BASH_ENV: ".circleci/shared" + working_directory: ~/.emacs.d + steps: + - checkout + - run: + name: Select changed files + command: .circleci/select_pr_changed + - run: + name: validate changed documentation files + command: .circleci/org/validate + "Update built-in files": + docker: + - image: jare/spacemacs-circleci:latest + environment: + - PRJ_OWNER: << pipeline.parameters.prj_owner >> + - PRJ_REPO: << pipeline.parameters.prj_repo >> + - BASH_ENV: ".circleci/shared" + - PUBLISH: "spacemacs_built_in" + - UPD_BOT_LOGIN: "SpacemacsBot" + - UPD_BOT_REPO: "spacemacs" + working_directory: ~/.emacs.d + steps: + - checkout + - run: + name: Initialize bot account + command: .circleci/bot_init + - run: + name: Download latest versions + command: .circleci/built_in/upd_built_in + - run: + name: Create patch file with the updates + command: .circleci/built_in/make_patch + - run: + name: Apply the patch file + command: .circleci/apply_patch + - run: + name: Push changes to Spacemacs Bot account + command: .circleci/push + - run: + name: Open PR if built in files must be updated + command: .circleci/built_in/maybe_pr + "Update documentation files": + docker: + - image: jare/spacemacs-circleci:latest + environment: + - PRJ_OWNER: << pipeline.parameters.prj_owner >> + - PRJ_REPO: << pipeline.parameters.prj_repo >> + - BASH_ENV: ".circleci/shared" + - PUBLISH: "spacemacs_fix_org" + - UPD_BOT_LOGIN: "SpacemacsBot" + - UPD_BOT_REPO: "spacemacs" + working_directory: ~/.emacs.d + steps: + - checkout + - run: + name: Initialize bot account + command: .circleci/bot_init + - run: + name: Export documentation files + command: .circleci/org/sdnize + - run: + name: Update documentation files + command: .circleci/org/update_docs + - run: + name: Create patch file with the updates + command: .circleci/org/make_patch + - run: + name: Apply the patch file + command: .circleci/apply_patch + - run: + name: Push changes to Spacemacs Bot account + command: .circleci/push + - run: + name: Open PR if documentation needs fixes + command: .circleci/org/maybe_pr + +workflows: + version: 2.1 + validate-pr-files: + when: + not: + equal: [ << pipeline.parameters.is_branch_update >>, "yes"] + jobs: + - "Validate PR" + - "Validate Documentation" + update-documentation: + when: + equal: [ << pipeline.parameters.is_branch_update >>, "yes"] + jobs: + - "Update documentation files" + update-built-in: + when: + equal: [ << pipeline.parameters.is_branch_update >>, "yes"] + triggers: + - schedule: + cron: "0 0,6,12,18 * * *" + filters: + branches: + only: + - develop + jobs: + - "Update built-in files" diff --git a/.circleci/org/export b/.circleci/org/export deleted file mode 100755 index 214050270..000000000 --- a/.circleci/org/export +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -## Export script for .org validation. -## -## Copyright (c) 2012-2014 Sylvain Benner -## Copyright (c) 2014-2018 Sylvain Benner & Contributors -## -## Author: Eugene Yaremenko -## URL: https://github.com/syl20bnr/spacemacs -## -## This file is not part of GNU Emacs. -## -## License: GPLv3 - -skip_when_branch_update -fail_when_undefined_pr_number - -select_changed_orgs -if [ ${#changed_f_as_args[@]} -ne 0 ]; then - emacs -batch -l /opt/spacetools/spacedoc/sdnize/sdnize.el -no-site-file \ - -q ~/.emacs.d/ /tmp/exported/ \ - $(printf "%s " "${changed_f_as_args[@]}") - if [ $? -ne 0 ]; then - echo "Documentation needs some fixing ;)" - exit 1 - fi -else - echo "This commit doesn't change documentation files." -fi diff --git a/.circleci/org/make_patch b/.circleci/org/make_patch new file mode 100755 index 000000000..0c9f04d0f --- /dev/null +++ b/.circleci/org/make_patch @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +## make_patch Generate patch file with Spacemacs documentation updates. +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +git add --all +git commit -m "documentation formatting: $(date -u)" +if [ $? -ne 0 ]; then + echo "Documentation is up to date." + exit 0 +else + git format-patch -1 HEAD --stdout > "/tmp/${PUBLISH}.patch" + if [ $? -ne 0 ]; then + echo "Failed to create documentation patch file." + exit 2 + fi + git reset --hard HEAD~1 + cat "/tmp/${PUBLISH}.patch" +fi diff --git a/.circleci/org/maybe_pr b/.circleci/org/maybe_pr new file mode 100755 index 000000000..889d51d1d --- /dev/null +++ b/.circleci/org/maybe_pr @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +## open_pr Opens PR to Spacemacs repository with documentation updates +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +echo_headline "Opening PR to ${UPD_BOT_LOGIN}/${UPD_BOT_REPO} repo" +echo "[bot] Documentation fixes" > msg +echo >> msg +echo "Merge with care - I'm just a stupid bot. Beep boop." >> msg +hub pull-request -h "${PUBLISH}" -b "${CIRCLE_BRANCH}" -F msg +if [ $? -ne 0 ]; then + echo "Seems like PR already exists (not a problem)" +fi diff --git a/.circleci/org/sdnize b/.circleci/org/sdnize new file mode 100755 index 000000000..ef9ff8796 --- /dev/null +++ b/.circleci/org/sdnize @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +## Export script for documentation files. +## +## Copyright (c) 2012-2014 Sylvain Benner +## Copyright (c) 2014-2022 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +mkdir -p "/tmp/sdn/" +echo_headline "Extract data out of documentation files into .sdn" +emacs -batch \ + -l /opt/spacetools/spacedoc/sdnize/sdnize \ + -no-site-file \ + -q \ + ~/.emacs.d/ \ + /tmp/sdn/ diff --git a/.circleci/org/update_docs b/.circleci/org/update_docs new file mode 100755 index 000000000..3aaca6bae --- /dev/null +++ b/.circleci/org/update_docs @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +## fix_docs Fixed(formats) Spacemacs' documentation files. +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +echo_headline "Generating new layers indext file data" +spacedoc layers \ + -c".ci/spacedoc-cfg.edn" \ + "/tmp/sdn/" +if [ $? -ne 0 ]; then + echo "Layers index generation failed." + exit 2 +fi + +echo_headline "Generating new .org files from .sdn representation" +spacedoc orgify \ + -c".ci/spacedoc-cfg.edn" \ + /tmp/sdn/ \ + ~/.emacs.d/ +if [ $? -ne 0 ]; then + echo "Documentation generation failed." + exit 2 +fi diff --git a/.circleci/org/validate b/.circleci/org/validate index e36fe4bcb..5e69d4c4e 100755 --- a/.circleci/org/validate +++ b/.circleci/org/validate @@ -1,8 +1,8 @@ #!/usr/bin/env bash -## Script for validating exported(org->sdn) documentation files. +## Script for validating documentation files. ## ## Copyright (c) 2012-2014 Sylvain Benner -## Copyright (c) 2014-2018 Sylvain Benner & Contributors +## Copyright (c) 2014-2021 Sylvain Benner & Contributors ## ## Author: Eugene Yaremenko ## URL: https://github.com/syl20bnr/spacemacs @@ -11,14 +11,33 @@ ## ## License: GPLv3 -skip_when_branch_update fail_when_undefined_pr_number select_changed_orgs + +echo_headline "Exporting changed org fils" +if [ ${#changed_f_as_args[@]} -ne 0 ]; then + emacs -batch \ + -l /opt/spacetools/spacedoc/sdnize/sdnize \ + -no-site-file \ + -q \ + ~/.emacs.d/ \ + /tmp/exported/ \ + $(printf "%s " "${changed_f_as_args[@]}") + if [ $? -ne 0 ]; then + echo "Documentation needs some fixing ;)" + exit 1 + fi +else + echo "This commit doesn't change documentation files." + exit 0 +fi + +echo_headline "Validating changed org fils" if [ ${#changed_f_as_args[@]} -ne 0 ]; then spacedoc validate -c".ci/spacedoc-cfg.edn" /tmp/exported/ if [ $? -ne 0 ]; then - echo "Documentation validation failed." + echo "Documentation is invalid." exit 1 fi else diff --git a/.circleci/push b/.circleci/push new file mode 100755 index 000000000..cd4b04e0c --- /dev/null +++ b/.circleci/push @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +## push Push changes to Spacemacs bot account. +## +## Copyright (c) 2014-2021 Sylvain Benner & Contributors +## +## Author: Eugene Yaremenko +## URL: https://github.com/syl20bnr/spacemacs +## +## This file is not part of GNU Emacs. +## +## License: GPLv3 + +echo_headline "Creating fork under bot account" +export GITHUB_TOKEN=$UPD_BOT_GIT_TK +hub fork +if [ $? -ne 0 ]; then + echo "hub fork failed" + exit 2 +fi +fork_url="https://${UPD_BOT_LOGIN}:${UPD_BOT_GIT_TK}" +fork_url+="@github.com/${UPD_BOT_LOGIN}/${UPD_BOT_REPO}.git" +git remote set-url "${UPD_BOT_LOGIN}" "${fork_url}" +echo_headline "Pushing changes" +hub push -f "${UPD_BOT_LOGIN}" "${PUBLISH}" > /dev/null 2>&1 +# prevent token leak ^^^^^^^^^^^^^^ +if [ $? -ne 0 ]; then + echo "hub push failed" + exit 2 +fi diff --git a/.circleci/select_pr_changed b/.circleci/select_pr_changed index 8f77c4d2b..9cfc44ec2 100755 --- a/.circleci/select_pr_changed +++ b/.circleci/select_pr_changed @@ -11,7 +11,6 @@ ## ## License: GPLv3 -skip_when_branch_update fail_when_undefined_pr_number files_json=$(curl "${pr_file_list_URL}" --silent) diff --git a/.circleci/shared b/.circleci/shared index 7319c056a..523fd07e6 100755 --- a/.circleci/shared +++ b/.circleci/shared @@ -12,10 +12,8 @@ ## License: GPLv3 # Vars -dev_b="develop" -mst_b="master" -prj_owner="syl20bnr" -prj_repo="spacemacs" +prj_owner="${PRJ_OWNER}" +prj_repo="${PRJ_REPO}" api_URL_root="https://api.github.com" upstream_data_URL_root="${api_URL_root}/" @@ -63,22 +61,3 @@ fail_when_undefined_pr_number () { exit 1 fi } - -skip_when_branch_update () { - if [[ "${IS_BRANCH_UPDATE}" == "yes" ]]; then - echo "Skipping for branch update." - exit 0 - fi -} - -skip_when_non_official_repo () { - if [[ "${CIRCLE_PROJECT_REPONAME}" != "${prj_repo}" || \ - "${CIRCLE_PROJECT_USERNAME}" != "${prj_owner}" ]]; then - echo "Skipping for non official repository." - exit 0 - fi -} - -cleanup () { - rm -rf ~/.emacs.d/elpa ~/.emacs.d/.cache /tmp/* ~/.spacemacs -} diff --git a/.circleci/update/maybe_pr b/.circleci/update/maybe_pr deleted file mode 100755 index 21d6517fe..000000000 --- a/.circleci/update/maybe_pr +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -## open_pr Opens PR to Spacemacs repository with built-in updates -## -## Copyright (c) 2014-2021 Sylvain Benner & Contributors -## -## Author: Eugene Yaremenko -## URL: https://github.com/syl20bnr/spacemacs -## -## This file is not part of GNU Emacs. -## -## License: GPLv3 - -skip_when_non_official_repo - -if [ ! -f /tmp/built_in.patch ]; then - echo "Nothing to update." - exit 0 -fi - -echo_headline "Cloning target repository" -target_URL="https://github.com/${prj_owner}/${prj_repo}.git" -git clone "${target_URL}" -b "${CIRCLE_BRANCH}" "/tmp/${PUBLISH}" -if [ $? -ne 0 ]; then - echo "Failed to clone \"${target_URL}\"" - exit 2 -fi - -cd "/tmp/${PUBLISH}" - -echo_headline "Applying built-in patch" -if [ ! -f /tmp/built_in.patch ]; then - echo "Built-in files don't need updating. Aborting." -else - git am < /tmp/built_in.patch - if [ $? -ne 0 ]; then - echo "Failed to apply built-in patch." - exit 2 - fi - -fi - -echo_headline "Forking target repository" -export GITHUB_TOKEN=$UPD_BOT_GIT_TK -hub fork -if [ $? -ne 0 ]; then - echo "hub fork failed" - exit 2 -fi -fork_url="https://${UPD_BOT_LOGIN}:${UPD_BOT_GIT_TK}" -fork_url+="@github.com/${UPD_BOT_LOGIN}/${UPD_BOT_REPO}.git" -git remote set-url "${UPD_BOT_LOGIN}" "${fork_url}" - -echo_headline "Pushing changes" -hub push -f "${UPD_BOT_LOGIN}" "${PUBLISH}" > /dev/null 2>&1 -# prevent token leak ^^^^^^^^^^^^^^ -if [ $? -ne 0 ]; then - echo "hub push failed" - exit 2 -fi - -echo_headline "Opening PR to ${UPD_BOT_LOGIN}/${UPD_BOT_REPO} repo" -echo "[bot] Built-in auto-update" > msg -echo >> msg -echo "Merge with care - I'm just a stupid bot. Beep boop." >> msg -hub pull-request -b "${CIRCLE_BRANCH}" -F msg -if [ $? -ne 0 ]; then - echo "Seems like PR already exists (not a problem)" -fi - -echo_headline "Done!" diff --git a/README.md b/README.md index bb4d1943b..ab7536575 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@

Gitter - Donate Donate Recommend it