Skip to content
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
29 changes: 29 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Nightly check for sustainability

on:
schedule:
- cron: "0 10 * * *" # 5 AM EST (GitHub Actions uses UTC)
workflow_dispatch:

jobs:
run-nightly-script:
name: Run nightly sustainability check
runs-on: ubuntu-latest

steps:
- name: Checkout default branch
uses: actions/checkout@v4
with:
fetch-depth: 0 # optional: fetch full history if needed

- name: Install GH extension
run: gh extension install kassett/gh-commit
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run nightly script
shell: bash
run: ./integrationTests/general.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// VERSION number: changed in CI
const VERSION = "v0.2.0"
const VERSION = "v0.2.1"

var rootPath string
var repo repository.Repository
Expand Down
109 changes: 109 additions & 0 deletions integrationTests/general.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash

current_branch=$(git rev-parse --abbrev-ref HEAD)

for i in {1..2}; do
mkdir tmp > /dev/null 2>&1
echo "RANDOM1" > tmp/random1.txt
echo "RANDOM2" > tmp/random2.txt

branch=$(echo random-nightly-branch-$(date +%F)-$((RANDOM % 100 + 1)))

if [[ $i -eq 1 ]]; then
gh commit tmp/random1.txt tmp/random2.txt \
-m "Randomly commit for nightly test." \
-B $branch
else
gh commit -U -A \
-m "Randomly commit for nightly test." \
-B $branch
fi

git fetch
git checkout $branch

cat tmp/random1.txt
cat tmp/random2.txt

rm -rf tmp

git switch -
sleep 1

repo_info=$(gh repo view --json owner,name -q '.owner.login + "/" + .name')
gh api -X DELETE repos/$repo_info/git/refs/heads/$branch
git checkout $current_branch
done

for i in {1..2}; do
mkdir tmp > /dev/null 2>&1
echo "RANDOM1" > tmp/random1.txt
echo "RANDOM2" > tmp/random2.txt

branch=$(echo random-nightly-branch-$(date +%F)-$((RANDOM % 100 + 1)))

if [[ $i -eq 1 ]]; then
gh commit tmp/random1.txt tmp/random2.txt \
-m "Randomly commit for nightly test." \
-B $branch
else
gh commit -U -A \
-m "Randomly commit for nightly test." \
-B $branch
fi

git fetch
git checkout $branch

cat tmp/random1.txt
cat tmp/random2.txt

rm -rf tmp

git switch -
sleep 1

repo_info=$(gh repo view --json owner,name -q '.owner.login + "/" + .name')
gh api -X DELETE repos/$repo_info/git/refs/heads/$branch
git checkout $current_branch
done


for i in {1..2}; do
mkdir tmp > /dev/null 2>&1
echo "RANDOM1" > tmp/random1.txt
echo "RANDOM2" > tmp/random2.txt

branch=$(echo random-nightly-branch-$(date +%F)-$((RANDOM % 100 + 1)))
headRef=$(echo random-nightly-branch-$(date +%F)-$((RANDOM % 1000 + 1)))

if [[ $i -eq 1 ]]; then
gh commit tmp/random1.txt tmp/random2.txt -P \
-m "Randomly commit for nightly test." \
-B $branch -H $headRef -T "Title of PR"
else
gh commit -U -A \
-m "Randomly commit for nightly test." -P \
-B $branch -H $headRef -T "Title of PR"
fi

git fetch
git checkout $branch

cat tmp/random1.txt
cat tmp/random2.txt

rm -rf tmp

git switch -
sleep 1

pr_number=$(gh pr list --head "$headRef" --json number -q '.[0].number')
echo $pr_number

repo_info=$(gh repo view --json owner,name -q '.owner.login + "/" + .name')
gh pr close $pr_number
gh api -X DELETE repos/$repo_info/git/refs/heads/$branch
gh api -X DELETE repos/$repo_info/git/refs/heads/$headRef
git checkout $current_branch
done