Skip to content

Commit 84425d6

Browse files
committed
Improve makefile
1 parent aa91e14 commit 84425d6

File tree

8 files changed

+217
-126
lines changed

8 files changed

+217
-126
lines changed

.devcontainer/.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ MINIO_ROOT_PASSWORD=minioadmin
1010

1111
# Azure Blob tests
1212
AZURE_STORAGE_ACCOUNT=devstoreaccount1
13-
AZURE_STORAGE_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
13+
AZURE_STORAGE_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
1414
AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;"
1515
AZURE_STORAGE_ENDPOINT=http://localhost:10000/devstoreaccount1
1616
AZURE_ALLOW_HTTP=true
1717
AZURE_TEST_CONTAINER_NAME=testcontainer
18-
AZURE_TEST_READ_ONLY_SAS="se=2100-05-05&sp=r&sv=2022-11-02&sr=c&sig=YMPFnAHKe9y0o3hFegncbwQTXtAyvsJEgPB2Ne1b9CQ%3D"
19-
AZURE_TEST_READ_WRITE_SAS="se=2100-05-05&sp=rcw&sv=2022-11-02&sr=c&sig=TPz2jEz0t9L651t6rTCQr%2BOjmJHkM76tnCGdcyttnlA%3D"
18+
AZURE_TEST_READ_ONLY_SAS=se=2100-05-05&sp=r&sv=2022-11-02&sr=c&sig=YMPFnAHKe9y0o3hFegncbwQTXtAyvsJEgPB2Ne1b9CQ%3D
19+
AZURE_TEST_READ_WRITE_SAS=se=2100-05-05&sp=rcw&sv=2022-11-02&sr=c&sig=TPz2jEz0t9L651t6rTCQr%2BOjmJHkM76tnCGdcyttnlA%3D
2020

2121
# http(s) tests
2222
ALLOW_HTTP=true
2323
HTTP_ENDPOINT=http://localhost:8080
2424

2525
# GCS tests
2626
GOOGLE_TEST_BUCKET=testbucket
27-
GOOGLE_SERVICE_ACCOUNT_KEY='{"gcs_base_url": "http://localhost:4443","disable_oauth": true,"client_email": "","private_key_id": "","private_key": ""}'
27+
GOOGLE_SERVICE_ACCOUNT_KEY={"gcs_base_url":"http://localhost:4443","disable_oauth":true,"client_email":"","private_key_id":"","private_key":""}
2828
GOOGLE_SERVICE_ENDPOINT=http://localhost:4443
2929

3030
# Others

.github/workflows/ci.yml

Lines changed: 56 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI lints and tests
1+
name: Build and tests
22
on:
33
push:
44
branches: [ "main" ]
@@ -17,17 +17,27 @@ env:
1717

1818
jobs:
1919
build-and-test:
20-
runs-on: ubuntu-latest
2120
strategy:
2221
matrix:
2322
postgres: [ 14, 15, 16, 17 ]
23+
runs_on: [ 'ubuntu-22.04', 'ubuntu-22.04-arm' ]
24+
include:
25+
- runs_on: ubuntu-22.04
26+
arch: x64
27+
- runs_on: ubuntu-22.04-arm
28+
arch: arm64
29+
30+
runs-on: ${{ matrix.runs_on }}
31+
2432
env:
2533
PG_MAJOR: ${{ matrix.postgres }}
34+
PG_CONFIG: /usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config
2635

2736
steps:
2837
- uses: actions/checkout@v4
2938

30-
- name: Set up sccache
39+
- name: Set up sccache for x86_64
40+
if: ${{ matrix.arch == 'x64' }}
3141
run: |
3242
wget https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz
3343
tar -xzf sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz
@@ -38,13 +48,34 @@ jobs:
3848
SCCACHE_VERSION: 0.8.1
3949
SCCACHE_SHA256: "7203a4dcb3a67f3a0272366d50ede22e5faa3e2a798deaa4d1ea377b51c0ab0c"
4050

41-
- name: Set up Rust
51+
- name: Set up sccache for arm64
52+
if: ${{ matrix.arch == 'arm64' }}
53+
run: |
54+
wget https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/sccache-v$SCCACHE_VERSION-aarch64-unknown-linux-musl.tar.gz
55+
tar -xzf sccache-v$SCCACHE_VERSION-aarch64-unknown-linux-musl.tar.gz
56+
sudo mv sccache-v$SCCACHE_VERSION-aarch64-unknown-linux-musl/sccache /usr/local/bin
57+
chmod +x /usr/local/bin/sccache
58+
echo "$SCCACHE_SHA256 /usr/local/bin/sccache" | sha256sum --check
59+
env:
60+
SCCACHE_VERSION: 0.8.1
61+
SCCACHE_SHA256: "36b2fd1c6c3a104ec1d526edb0533a3827c266054bf4552fb97f524beff6a612"
62+
63+
- name: Set up Rust for x86_64
64+
if: ${{ matrix.arch == 'x64' }}
4265
uses: dtolnay/rust-toolchain@stable
4366
with:
4467
toolchain: 1.86.0
4568
target: x86_64-unknown-linux-gnu
4669
components: rustfmt, clippy, llvm-tools-preview
4770

71+
- name: Set up Rust for arm64
72+
if: ${{ matrix.arch == 'arm64' }}
73+
uses: dtolnay/rust-toolchain@stable
74+
with:
75+
toolchain: 1.86.0
76+
target: aarch64-unknown-linux-gnu
77+
components: rustfmt, clippy, llvm-tools-preview
78+
4879
- name: Cache cargo registry
4980
uses: actions/cache@v4
5081
continue-on-error: false
@@ -56,21 +87,14 @@ jobs:
5687
~/.cargo/registry/index
5788
~/.cargo/registry/cache
5889
~/.cargo/git/db
59-
key: pg_parquet-rust-cache-${{ runner.os }}-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
90+
key: pg_parquet-rust-cache-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
6091

6192
- name: Cache sccache directory
6293
uses: actions/cache@v4
6394
continue-on-error: false
6495
with:
6596
path: ${{ env.SCCACHE_DIR }}
66-
key: pg_parquet-sccache-cache-${{ runner.os }}-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
67-
68-
- name: Export environment variables from .env file
69-
uses: falti/dotenv-action@v1
70-
with:
71-
path: .devcontainer/.env
72-
export-variables: true
73-
keys-case: bypass
97+
key: pg_parquet-sccache-cache-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
7498

7599
- name: Install PostgreSQL
76100
run: |
@@ -96,97 +120,38 @@ jobs:
96120
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
97121
sudo apt-get update && sudo apt-get install -y azure-cli
98122
99-
- name: Install and configure pgrx
123+
- name: Install pgrx
100124
run: |
101125
cargo install --locked [email protected]
102-
cargo pgrx init --pg${{ env.PG_MAJOR }} /usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config \
103-
--base-testing-port $PGRX_TEST_PG_BASE_PORT
104126
105127
- name: Install cargo-llvm-cov for coverage report
106128
run: cargo install --locked [email protected]
107129

108-
- name: Format and lint
109-
run: |
110-
cargo fmt --all -- --check
111-
cargo clippy --all-targets --features "pg${{ env.PG_MAJOR }}, pg_test" --no-default-features -- -D warnings
112-
113130
- name: Set up permissions for PostgreSQL
114131
run: |
115132
sudo chmod a+rwx $(/usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config --pkglibdir) \
116133
$(/usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config --sharedir)/extension \
117134
/var/run/postgresql/
118135
119-
- name: Start Minio for s3 emulator tests
120-
run: |
121-
docker run -d \
122-
--env-file .devcontainer/.env \
123-
-p 9000:9000 \
124-
--entrypoint "./entrypoint.sh" \
125-
--volume ./.devcontainer/minio-entrypoint.sh:/entrypoint.sh \
126-
minio/minio
127-
128-
while ! curl $AWS_ENDPOINT_URL; do
129-
echo "Waiting for $AWS_ENDPOINT_URL..."
130-
sleep 1
131-
done
132-
133-
- name: Start Azurite for Azure Blob Storage emulator tests
136+
- name: Check format and lint
134137
run: |
135-
docker run -d \
136-
--env-file .devcontainer/.env \
137-
-p 10000:10000 \
138-
mcr.microsoft.com/azure-storage/azurite
138+
make check-format
139+
make check-lint
139140
140-
while ! curl $AZURE_STORAGE_ENDPOINT; do
141-
echo "Waiting for $AZURE_STORAGE_ENDPOINT..."
142-
sleep 1
143-
done
141+
# - name: Run tests with coverage
142+
# if: ${{ env.PG_MAJOR }} == 17 || ${{ matrix.arch == 'x64' }}
143+
# run: |
144+
# make check-with-coverage
144145

145-
# create container
146-
az storage container create -n $AZURE_TEST_CONTAINER_NAME --connection-string $AZURE_STORAGE_CONNECTION_STRING
147-
az storage container create -n ${AZURE_TEST_CONTAINER_NAME}2 --connection-string $AZURE_STORAGE_CONNECTION_STRING
148-
149-
- name: Start local web server for http(s) tests
146+
- name: Run tests without coverage
147+
if: ${{ env.PG_MAJOR }} != 17 || ${{ matrix.arch != 'x64' }}
150148
run: |
151-
docker run -d \
152-
--env-file .devcontainer/.env \
153-
-p 8080:80 \
154-
rclone/rclone serve webdav /data --addr :80
155-
156-
while ! curl $HTTP_ENDPOINT; do
157-
echo "Waiting for $HTTP_ENDPOINT..."
158-
sleep 1
159-
done
160-
161-
- name: Start fake-gcs-server for Google Cloud Storage emulator tests
162-
run: |
163-
docker run -d \
164-
--env-file .devcontainer/.env \
165-
-p 4443:4443 \
166-
tustvold/fake-gcs-server -scheme http -public-host localhost:4443
167-
168-
while ! curl $GOOGLE_SERVICE_ENDPOINT; do
169-
echo "Waiting for $GOOGLE_SERVICE_ENDPOINT..."
170-
sleep 1
171-
done
172-
173-
# create bucket
174-
curl -v -X POST --data-binary "{\"name\":\"$GOOGLE_TEST_BUCKET\"}" -H "Content-Type: application/json" "$GOOGLE_SERVICE_ENDPOINT/storage/v1/b"
175-
curl -v -X POST --data-binary "{\"name\":\"${GOOGLE_TEST_BUCKET}2\"}" -H "Content-Type: application/json" "$GOOGLE_SERVICE_ENDPOINT/storage/v1/b"
176-
177-
- name: Run tests
178-
run: |
179-
# Run tests with coverage tool
180-
source <(cargo llvm-cov show-env --export-prefix)
181-
cargo llvm-cov clean
182-
cargo build --features "pg${{ env.PG_MAJOR }}, pg_test" --no-default-features
183-
cargo pgrx test pg${{ env.PG_MAJOR }} --no-default-features
184-
cargo llvm-cov report --lcov > lcov.info
185-
186-
- name: Upload coverage report to Codecov
187-
if: ${{ env.PG_MAJOR }} == 17
188-
uses: codecov/codecov-action@v4
189-
with:
190-
fail_ci_if_error: true
191-
files: ./lcov.info
192-
token: ${{ secrets.CODECOV_TOKEN }}
149+
make check
150+
151+
# - name: Upload coverage report to Codecov
152+
# if: ${{ env.PG_MAJOR }} == 17 && ${{ matrix.arch == 'x64' }}
153+
# uses: codecov/codecov-action@v4
154+
# with:
155+
# fail_ci_if_error: true
156+
# files: ./lcov.info
157+
# token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
*.xml
1414
lcov.info
1515
playground.rs
16+
*.env

CONTRIBUTING.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,19 @@ testing via `cargo pgrx test pg16`.
9191

9292
# Testing
9393

94-
We run `RUST_TEST_THREADS=1 cargo pgrx test` to run all our unit tests. If you
95-
run a specific test, you can do it via regex patterns like below:
96-
`cargo pgrx run pg17 test_numeric_*`.
94+
Object storage tests are integration tests which require below containers running locally:
95+
- minio container for s3
96+
- azurite container for azure blob storage
97+
- fake_gcs container for google cloud storage
98+
- webdav container for http(s) stores
9799

98-
> [!WARNING]
99-
> Make sure to pass RUST_TEST_THREADS=1 as environment variable to `cargo pgrx test`.
100-
101-
Object storage tests are integration tests which require a storage emulator running
102-
locally. See [ci.yml](.github/workflows/ci.yml) to see how local storage emulators
103-
are started. You can also see the required environment variables from
104-
[.env file](.devcontainer/.env).
100+
Our [Makefile](Makefile) automates setting up all containers and running tests for pg_parquet.
105101

106102
# Format and Lint
107103

108104
We use `cargo-fmt` as formatter and `cargo-clippy` as linter. You can check
109105
how we run them from [ci.yml](.github/workflows/ci.yml).
110106

111-
112107
# Release
113108

114109
We apply semantic versioning for our releases. We do not support long term release branches (backporting) yet.

0 commit comments

Comments
 (0)