Skip to content

Commit 6b7be4e

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 202a246 + a74a1d3 commit 6b7be4e

File tree

31 files changed

+399
-125
lines changed

31 files changed

+399
-125
lines changed

.devcontainer/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM mcr.microsoft.com/devcontainers/java:21
2+
3+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends libpq-dev

.devcontainer/devcontainer.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"dockerComposeFile": "docker-compose.yml",
3+
"service": "app",
4+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
5+
"features": {
6+
"ghcr.io/devcontainers/features/sshd:1": {}
7+
},
8+
9+
"forwardPorts": [
10+
5432
11+
]
12+
}

.devcontainer/docker-compose.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
container_name: javadev
6+
# https://youtrack.jetbrains.com/issue/KT-36871/Support-Aarch64-Linux-as-a-host-for-the-Kotlin-Native
7+
platform: "linux/amd64"
8+
build:
9+
context: .
10+
dockerfile: Dockerfile
11+
environment:
12+
POSTGRES_HOSTNAME: postgresdb
13+
POSTGRES_DB: postgres
14+
POSTGRES_USER: postgres
15+
POSTGRES_PASSWORD: password
16+
17+
volumes:
18+
- ../..:/workspaces:cached
19+
20+
command: sleep infinity
21+
22+
network_mode: service:db
23+
24+
db:
25+
container_name: postgresdb
26+
image: postgres:latest
27+
restart: unless-stopped
28+
healthcheck:
29+
test: [ "CMD-SHELL", "pg_isready" ]
30+
interval: 1s
31+
timeout: 5s
32+
retries: 10
33+
environment:
34+
POSTGRES_DB: postgres
35+
POSTGRES_USER: postgres
36+
POSTGRES_PASSWORD: password
37+
ports:
38+
- "5432:5432"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Setup PostgreSQL for Linux/macOS/Windows
2+
author: Ihor Kalnytskyi
3+
description: Setup a preinstalled PostgreSQL server.
4+
branding:
5+
icon: database
6+
color: purple
7+
inputs:
8+
username:
9+
description: The username of the user to setup.
10+
default: postgres
11+
required: false
12+
password:
13+
description: The password of the user to setup.
14+
default: postgres
15+
required: false
16+
database:
17+
description: The database name to setup and grant permissions to created user.
18+
default: postgres
19+
required: false
20+
port:
21+
description: The server port to listen on.
22+
default: "5432"
23+
required: false
24+
outputs:
25+
connection-uri:
26+
description: The connection URI to connect to PostgreSQL.
27+
value: ${{ steps.set-outputs.outputs.connection-uri }}
28+
service-name:
29+
description: The service name with connection parameters.
30+
value: ${{ steps.set-outputs.outputs.service-name }}
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Prerequisites
35+
run: |
36+
if [ "$RUNNER_OS" == "Linux" ]; then
37+
echo "$(pg_config --bindir)" >> $GITHUB_PATH
38+
elif [ "$RUNNER_OS" == "Windows" ]; then
39+
echo "$PGBIN" >> $GITHUB_PATH
40+
echo "PQ_LIB_DIR=$PGROOT\lib" >> $GITHUB_ENV
41+
42+
# The Windows runner has some PostgreSQL environment variables set
43+
# that may confuse users since they may be irrelevant to the
44+
# PostgreSQL server we're using.
45+
for name in "PGROOT" "PGDATA" "PGBIN" "PGUSER" "PGPASSWORD"; do
46+
echo "$name=" >> $GITHUB_ENV
47+
done
48+
elif [ "$RUNNER_OS" == "macOS" ]; then
49+
case "$(sw_vers -productVersion)" in
50+
12.*|13.*)
51+
brew install postgresql@14
52+
echo "/usr/local/opt/postgresql@14/bin" >> $GITHUB_PATH
53+
;;
54+
14.*)
55+
brew install postgresql@16
56+
echo "/opt/homebrew/opt/postgresql@16/bin" >> $GITHUB_PATH
57+
;;
58+
esac
59+
fi
60+
shell: bash
61+
62+
- name: Setup and start PostgreSQL
63+
run: |
64+
export PGDATA="$RUNNER_TEMP/pgdata"
65+
export PWFILE="$RUNNER_TEMP/pwfile"
66+
67+
# Unfortunately 'initdb' could only receive a password via file on disk
68+
# or prompt to enter on. Prompting is not an option since we're running
69+
# in non-interactive mode.
70+
echo '${{ inputs.password }}' > $PWFILE
71+
72+
# There are couple of reasons why we need to create a new PostgreSQL
73+
# database cluster. First and foremost, we have to create a superuser
74+
# with provided credentials. Second, we want the PostgreSQL client
75+
# applications [1] to be available for execution without
76+
# run-from-another-user dances. Third, we want to make sure that
77+
# settings are the same between operating systems and aren't changed by
78+
# package vendors.
79+
#
80+
# [1] https://www.postgresql.org/docs/15/reference-client.html
81+
initdb \
82+
--username="${{ inputs.username }}" \
83+
--pwfile="$PWFILE" \
84+
--auth="scram-sha-256" \
85+
--encoding="UTF-8" \
86+
--locale="en_US.UTF-8" \
87+
--no-instructions
88+
89+
# Do not create unix sockets since they are created by default in the
90+
# directory we have no permissions to (owned by system postgres user).
91+
echo "unix_socket_directories = ''" >> "$PGDATA/postgresql.conf"
92+
echo "port = ${{ inputs.port }}" >> "$PGDATA/postgresql.conf"
93+
pg_ctl start
94+
95+
# Save required connection parameters for created superuser to the
96+
# connection service file [1]. This allows using these connection
97+
# parameters by setting 'PGSERVICE' environment variable or by
98+
# requesting them via connection string.
99+
#
100+
# HOST is required for Linux/macOS because these OS-es default to unix
101+
# sockets but we turned them off.
102+
#
103+
# PORT, USER, PASSWORD and DBNAME are required because they could be
104+
# parametrized via action input parameters.
105+
#
106+
# [1] https://www.postgresql.org/docs/15/libpq-pgservice.html
107+
cat <<EOF > "$PGDATA/pg_service.conf"
108+
[${{ inputs.username }}]
109+
host=localhost
110+
port=${{ inputs.port }}
111+
user=${{ inputs.username }}
112+
password=${{ inputs.password }}
113+
dbname=${{ inputs.database }}
114+
EOF
115+
echo "PGSERVICEFILE=$PGDATA/pg_service.conf" >> $GITHUB_ENV
116+
shell: bash
117+
118+
- name: Setup PostgreSQL database
119+
run: |
120+
# The 'postgres' database is a pre-created database meant for use by
121+
# users, utilities and third party applications. There's no way to
122+
# parametrize the name, so all we can do is to avoid creating a
123+
# database if provided name is 'postgres'.
124+
if [ "${{ inputs.database }}" != "postgres" ]; then
125+
createdb -O "${{ inputs.username }}" "${{ inputs.database }}"
126+
fi
127+
env:
128+
PGSERVICE: ${{ inputs.username }}
129+
shell: bash
130+
131+
- name: Set action outputs
132+
run: |
133+
CONNECTION_URI="postgresql://${{ inputs.username }}:${{ inputs.password }}@localhost:${{ inputs.port }}/${{ inputs.database }}"
134+
135+
echo "connection-uri=$CONNECTION_URI" >> $GITHUB_OUTPUT
136+
echo "service-name=${{ inputs.username }}" >> $GITHUB_OUTPUT
137+
shell: bash
138+
id: set-outputs

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ updates:
1313
assignees:
1414
- "hfhbd"
1515
rebase-strategy: "disabled"
16+
- package-ecosystem: "devcontainers"
17+
directory: "/"
18+
schedule:
19+
interval: "daily"
20+
assignees:
21+
- "hfhbd"
22+
- package-ecosystem: "docker"
23+
directory: "/"
24+
schedule:
25+
interval: "daily"
26+
assignees:
27+
- "hfhbd"

.github/workflows/CD.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ on:
66

77
jobs:
88
build:
9-
runs-on: macos-latest
9+
runs-on: macos-14
1010

1111
steps:
1212
- name: Set environment for version
1313
run: long="${{ github.ref }}"; version=${long#"refs/tags/v"}; echo "version=${version}" >> $GITHUB_ENV
1414
- uses: actions/checkout@v4
1515
- uses: Homebrew/actions/setup-homebrew@master
1616
id: set-up-homebrew
17-
- uses: actions/setup-java@v3
17+
- uses: actions/setup-java@v4
1818
with:
1919
distribution: 'adopt'
2020
java-version: 17
21-
- uses: gradle/gradle-build-action@v2
21+
- uses: gradle/actions/setup-gradle@v3
2222
- run: brew install libpq
23-
- name: Build with Gradle
24-
run: ./gradlew assemble
23+
env:
24+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: true
2525
- name: Publish
26-
run: ./gradlew -Pversion=$version -Dorg.gradle.parallel=false publish closeAndReleaseStagingRepository
26+
run: ./gradlew -Pversion=$version -Dorg.gradle.parallel=false --no-configuration-cache publish closeAndReleaseStagingRepository
2727
env:
2828
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
2929
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/CI.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ jobs:
1313
contents: write
1414
strategy:
1515
matrix:
16-
os: [ 'ubuntu-latest', 'macos-latest' ]
16+
os: [ 'ubuntu-latest', 'macos-14', 'macos-latest' ]
17+
18+
env:
19+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: true
1720

1821
steps:
1922
- uses: actions/checkout@v4
2023
- uses: Homebrew/actions/setup-homebrew@master
2124
id: set-up-homebrew
2225
- run: brew install libpq
23-
- uses: actions/setup-java@v3
26+
- uses: ./.github/actions/action-setup-postgres
27+
with:
28+
password: password
29+
- uses: actions/setup-java@v4
2430
with:
2531
distribution: 'adopt'
2632
java-version: 17
27-
- uses: gradle/gradle-build-action@v2
33+
- uses: gradle/actions/setup-gradle@v3
2834
with:
29-
dependency-graph: generate-and-submit
3035
gradle-home-cache-cleanup: true
3136
- run: ./gradlew assemble
32-
- uses: ikalnytskyi/action-setup-postgres@v4
33-
with:
34-
password: password
3537
- run: ./gradlew build

.github/workflows/Docs.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ jobs:
2525
url: ${{ steps.deployment.outputs.page_url }}
2626

2727
steps:
28-
- uses: actions/configure-pages@v3
28+
- uses: actions/configure-pages@v4
2929
- uses: actions/checkout@v4
3030
- uses: Homebrew/actions/setup-homebrew@master
3131
id: set-up-homebrew
3232
- run: brew install libpq
33-
- uses: actions/setup-java@v3
33+
- uses: actions/setup-java@v4
3434
with:
3535
distribution: 'adopt'
3636
java-version: 17
37-
- uses: gradle/gradle-build-action@v2
37+
- uses: gradle/actions/setup-gradle@v3
3838
- name: Generate Docs
39-
run: ./gradlew :dokkaHtmlMultiModule
40-
- uses: actions/upload-pages-artifact@v2
39+
run: ./gradlew :dokkaHtmlMultiModule --no-configuration-cache
40+
- uses: actions/upload-pages-artifact@v3
4141
with:
4242
path: build/dokka/htmlMultiModule
4343
- name: Deploy to GitHub Pages
4444
id: deployment
45-
uses: actions/deploy-pages@main
45+
uses: actions/deploy-pages@v4

.github/workflows/dependencies.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Dependency review for pull requests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
dependency-submission:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
env:
16+
GRADLE_OPTS: -Dorg.gradle.caching=true
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-java@v4
21+
with:
22+
distribution: 'adopt'
23+
java-version: 17
24+
- uses: gradle/actions/dependency-submission@v3
25+
with:
26+
cache-encryption-key: ${{ secrets.CC }}
27+
28+
dependency-review:
29+
runs-on: ubuntu-latest
30+
needs: dependency-submission
31+
if: github.event_name == 'pull_request'
32+
33+
steps:
34+
- uses: actions/dependency-review-action@v4

.github/workflows/gradleWrapper.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: gradle/wrapper-validation-action@v1
18+
- uses: gradle/wrapper-validation-action@v2

0 commit comments

Comments
 (0)