Skip to content

Commit ad3f960

Browse files
committed
Update dev and CI tooling
1 parent 8fdb8a6 commit ad3f960

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

.github/workflows/elixir.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
merge_group:
9+
types: [checks_requested]
810

911
permissions:
1012
contents: read
@@ -23,8 +25,8 @@ jobs:
2325
- name: Set up Elixir
2426
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
2527
with:
26-
elixir-version: '1.15.2' # [Required] Define the Elixir version
27-
otp-version: '26.0' # [Required] Define the Erlang/OTP version
28+
elixir-version: '1.16.0' # [Required] Define the Elixir version
29+
otp-version: '26.2' # [Required] Define the Erlang/OTP version
2830
- name: Restore dependencies cache
2931
uses: actions/cache@v3
3032
with:
@@ -40,4 +42,6 @@ jobs:
4042
- name: Install dependencies
4143
run: mix deps.get
4244
- name: Run tests
45+
run: mix test
46+
- name: Run Quality Checks
4347
run: mix check

.github/workflows/release.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish Package
2+
on:
3+
release:
4+
types: [published]
5+
6+
env:
7+
OPENAI_API_KEY: afakekeyneededfortests
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Elixir
15+
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
16+
with:
17+
elixir-version: '1.16.0' # [Required] Define the Elixir version
18+
otp-version: '26.2' # [Required] Define the Erlang/OTP version
19+
- name: Restore dependencies cache
20+
uses: actions/cache@v3
21+
with:
22+
path: deps
23+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
24+
restore-keys: ${{ runner.os }}-mix-
25+
- name: Restore _build cache
26+
uses: actions/cache@v3
27+
with:
28+
path: _build
29+
key: ${{ runner.os }}-build-${{ hashFiles('**/*.ex') }}
30+
restore-keys: ${{ runner.os }}-build-
31+
- name: Install dependencies
32+
run: mix deps.get
33+
- name: Check version
34+
run: |
35+
MIX_VERSION=$(grep 'version:' mix.exs | cut -d '"' -f2)
36+
TAG_VERSION=${GITHUB_REF/refs\/tags\/v/}
37+
if [ "$MIX_VERSION" != "$TAG_VERSION" ]; then
38+
echo "Tag version ($TAG_VERSION) does not match mix.exs version ($MIX_VERSION)"
39+
exit 1
40+
fi
41+
- name: Publish to Hex
42+
uses: synchronal/hex-publish-action@v3
43+
with:
44+
name: gpt_agent
45+
key: ${{ secrets.HEX_API_KEY }}
46+
tag-release: false

integrate.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env sh
2+
3+
# This script is used to integrate your local changes with the remote
4+
# repository. See the documentation in the pre-commit-sample file for
5+
# information on what we check prior to committing and pushing your changes.
6+
# This script is intended as a convenient one-liner to commit your changes, push
7+
# them to the remote repository, and watch the GitHub Actions workflow run in
8+
# your terminal to ensure that the build is successful.
9+
10+
set -e
11+
12+
if [ ! -e ./.git/hooks/pre-commit ]; then
13+
ln -s ../../pre-commit-sample ./.git/hooks/pre-commit
14+
else
15+
if [ "$(readlink -f ./.git/hooks/pre-commit)" != "$(readlink -f ./pre-commit-sample)" ]; then
16+
echo "\n\n"
17+
echo "\e[1;31m"
18+
echo "**********************************************************************"
19+
echo "* Error: pre-commit hook conflict *"
20+
echo "* *"
21+
echo "* You have an existing pre-commit hook at ./.git/hooks/pre-commit, so *"
22+
echo "* we will not install the hook required by this script. Please *"
23+
echo "* review the hook in ./pre-commit-sample and consider removing your *"
24+
echo "* current pre-commit hook. *"
25+
echo "**********************************************************************"
26+
echo "\e[0m"
27+
echo "\n\n"
28+
exit 1
29+
fi
30+
fi
31+
32+
git add -N .
33+
git add -p
34+
git commit --no-verify -m "TEMPORARY UNTESTED COMMIT\n\nIf you are seeing this in the commit log, it probably means that the integrate.sh script failed. You should do a soft reset to the commit prior to this commit."
35+
36+
if git diff --exit-code; then
37+
echo "No uncommitted changes to stash"
38+
changes_stashed=0
39+
else
40+
echo "Stashing uncommitted changes"
41+
changes_stashed=1
42+
git restore --staged .
43+
git stash push --include-untracked -m "Temporary stash for uncommitted changes"
44+
fi
45+
46+
git pull --rebase
47+
git reset --soft HEAD^
48+
git status
49+
mix clean
50+
git commit
51+
git push
52+
if [ $changes_stashed -eq 1 ]; then
53+
git stash pop
54+
fi
55+
sleep 2
56+
gh run watch --exit-status

pre-commit-sample

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env sh
2+
3+
exec 1>&2
4+
5+
if ! git diff --exit-code; then
6+
echo "\n\n"
7+
echo "\e[1;31m"
8+
echo "**********************************************************************"
9+
echo "* Error: There are unstaged changes! *"
10+
echo "* *"
11+
echo "* You must run your pre-commit tests against the same code that will *"
12+
echo "* actually be commited, and the presence of unstaged changes will *"
13+
echo "* prevent that. We recommend using the integrate.sh script in this *"
14+
echo "* repository to take care of automatically stashing these changes *"
15+
echo "* for you. *"
16+
echo "**********************************************************************"
17+
echo "\e[0m"
18+
echo "\n\n"
19+
exit 1
20+
fi
21+
22+
mix check && \
23+
mix test

0 commit comments

Comments
 (0)