From 27ce912f418144fe674a1d2014494e7a37c6d196 Mon Sep 17 00:00:00 2001 From: Cameron Brown Date: Sun, 25 Aug 2024 00:00:34 -0400 Subject: [PATCH 1/2] Add autopush workflow --- .github/workflows/autopush.yaml | 98 +++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/autopush.yaml diff --git a/.github/workflows/autopush.yaml b/.github/workflows/autopush.yaml new file mode 100644 index 000000000..442ddb8d2 --- /dev/null +++ b/.github/workflows/autopush.yaml @@ -0,0 +1,98 @@ +--- +name: Autopush + +# yamllint disable-line rule:truthy +on: [push] + # push: + # branches: + # - autopush-* + +# Cancels this run if a new one referring to the same object and same workflow +# is requested +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + # The version of caching we are using. This can be upgraded if we + # significantly change CI to the point where old caches become irrelevant. + CACHE_VERSION: 0 + # Default Python version. Noetic defaults to 3.8. + DEFAULT_PYTHON: 3.8 + # Location of the pre-commit cache. This is set by pre-commit, not us! + PRE_COMMIT_CACHE: ~/.cache/pre-commit + +jobs: + pre-commit: + name: Run pre-commit + runs-on: ubuntu-latest + if: github.event.sender.login == 'cbrxyz' + steps: + - name: Check out code from GitHub + uses: actions/checkout@v3.0.2 + with: + submodules: recursive + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + uses: actions/setup-python@v4.1.0 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + cache: "pip" + - name: Install pre-commit hooks + run: | + python --version + pip install "$(cat requirements.txt | grep pre-commit)" + - name: Generate pre-commit cache key + id: pre-commit_cache_key + run: > + echo "::set-output + name=key::${{ env.CACHE_VERSION }}-${{ env.DEFAULT_PYTHON }}-${{ + hashFiles('.pre-commit-config.yaml') }}" + - name: Restore base pre-commit environment + id: cache-pre-commmit + uses: actions/cache@v3.0.4 + with: + path: ${{ env.PRE_COMMIT_CACHE }} + key: > + ${{ runner.os + }}-pre-commit-${{ steps.pre-commit_cache_key.outputs.key }} + - name: Install pre-commit dependencies if no cache + if: steps.cache-precommit.outputs.cache-hit != 'true' + run: | + pre-commit install-hooks + - name: Run pre-commit + run: | + pre-commit run --all-files --show-diff-on-failure + + autopush: + name: Autopush changes + needs: [pre-commit] + runs-on: ubuntu-latest + steps: + - name: Wait for tests to succeed + uses: lewagon/wait-on-check-action@v1.3.4 + with: + ref: ${{ github.ref }} + check-name: 'Run tests and build docs' + repo-token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }} + wait-interval: 10 + + - name: Check out code from GitHub + uses: actions/checkout@v3.0.2 + with: + submodules: recursive + token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }} + ref: ${{ github.event.ref }} + fetch-depth: 0 + + - name: Create commit + run: | + git fetch + git config --global user.name \ + "$(git --no-pager log --format=format:'%an' -n 1)" + git config --global user.email \ + "$(git --no-pager log --format=format:'%ae' -n 1)" + git rebase origin/main || cat .github/workflows/autopush.yaml + git checkout main + git branch + git merge --ff-only ${{ github.event.ref }} + # git push From ea76689d7b2583673779bc985542ba9af629fc78 Mon Sep 17 00:00:00 2001 From: Cameron Brown Date: Sun, 25 Aug 2024 00:20:00 -0400 Subject: [PATCH 2/2] Add autopush workflow, fix incorrect master branch name --- .github/workflows/autopush.yaml | 14 +++++++------- scripts/setup.bash | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/autopush.yaml b/.github/workflows/autopush.yaml index 442ddb8d2..824f4e2df 100644 --- a/.github/workflows/autopush.yaml +++ b/.github/workflows/autopush.yaml @@ -2,10 +2,10 @@ name: Autopush # yamllint disable-line rule:truthy -on: [push] - # push: - # branches: - # - autopush-* +on: + push: + branches: + - autopush-* # Cancels this run if a new one referring to the same object and same workflow # is requested @@ -91,8 +91,8 @@ jobs: "$(git --no-pager log --format=format:'%an' -n 1)" git config --global user.email \ "$(git --no-pager log --format=format:'%ae' -n 1)" - git rebase origin/main || cat .github/workflows/autopush.yaml - git checkout main + git rebase origin/master + git checkout master git branch git merge --ff-only ${{ github.event.ref }} - # git push + git push diff --git a/scripts/setup.bash b/scripts/setup.bash index 898809842..0d2f65273 100755 --- a/scripts/setup.bash +++ b/scripts/setup.bash @@ -133,6 +133,10 @@ cm() { fi } +autopush() { + git push origin +"${1:-HEAD}":refs/heads/cameron-autopush-"$(uuidgen --random | cut -c1-8)"-citmp +} + alias xbox=startxbox # PYTHONPATH modifications