Skip to content

Commit

Permalink
Fix CI: use new nginx and postgis actions (#1351)
Browse files Browse the repository at this point in the history
I recently released a new nginx github action that should work on all OS
and in all runners. Also, postgis action has been updated.
  • Loading branch information
nyurik authored May 25, 2024
1 parent f9f6777 commit d77533f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 110 deletions.
130 changes: 23 additions & 107 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ jobs:
mv target_releases/aarch64-unknown-linux-musl/* target_releases/linux/arm64/
mkdir -p target_releases/linux/amd64
mv target_releases/x86_64-unknown-linux-musl/* target_releases/linux/amd64/
- name: Start HTTP Server
run: |
docker run --rm -d \
--name fileserver \
-p 5412:80 \
-v ${{ github.workspace }}/tests/fixtures/pmtiles2:/usr/share/nginx/html \
nginx:alpine
- name: Start NGINX
uses: nyurik/[email protected]
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Build linux/arm64 Docker image
uses: docker/build-push-action@v5
# https://github.com/docker/build-push-action
Expand Down Expand Up @@ -328,108 +326,27 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v4
# - name: Install Docker (MacOS)
# if: runner.os == 'macos'
# run: brew install docker && colima start
- name: Start HTTP Server (with Docker)
if: matrix.os == 'ubuntu-latest'
run: |
docker run --rm -d \
--name fileserver \
-p 5412:80 \
-v ${{ github.workspace }}/tests/fixtures/pmtiles2:/usr/share/nginx/html \
nginx:alpine
- name: Start HTTP Server (MacOS, no Docker)
if: runner.os == 'macos'
run: |
mkdir -p /usr/local/etc/nginx
cat << EOF > /usr/local/etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 5412;
server_name localhost;
location / {
root $PWD/tests/fixtures/pmtiles2;
index index.html index.htm;
}
}
}
EOF
brew services info nginx
brew services start nginx
sleep 2
curl -I http://localhost:5412/
curl -I http://localhost:5412/webp2.pmtiles
- name: Start HTTP Server (Windows, no Docker)
if: runner.os == 'windows'
shell: pwsh
run: |
$nginxConf = @"
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 5412;
server_name localhost;
location / {
root $($PWD.Path)/tests/fixtures/pmtiles2;
index index.html index.htm;
}
}
}
"@
# Replace the default Nginx configuration file
echo "$nginxConf"
Set-Content -Path "C:\tools\nginx-1.25.4\conf\nginx.conf" -Value $nginxConf
Get-Content -Path "C:\tools\nginx-1.25.4\conf\nginx.conf"
# Start Nginx
#Get-Service -ErrorAction SilentlyContinue
#Get-CimInstance -ClassName Win32_Service
Set-Service nginx -StartupType manual
Start-Service nginx
#Start-Process -FilePath "C:\tools\nginx-1.25.4\nginx.exe"
dir C:\tools\nginx-1.25.4\logs\
Start-Sleep -Seconds 5
netstat -a
# Print Nginx Error Logs (on Windows systems)
#nginx -t
Get-Content -Path "C:\tools\nginx-1.25.4\logs\error.log"
dir D:\a\martin\martin\
- name: Start postgres
uses: nyurik/[email protected]
- name: Start NGINX
uses: nyurik/[email protected]
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Install and run Postgis
uses: nyurik/action-setup-postgis@v2
id: pg
with:
username: test
password: test
database: test
rights: --superuser
- name: Init database
run: |
echo "DATABASE_URL=$DATABASE_URL"
echo "DATABASE_URL=${{ steps.pg.outputs.connection-uri }}"
echo "Print the same in base64 to bypass Github's obfuscation (uses hardcoded password):"
echo "$DATABASE_URL" | base64
echo "${{ steps.pg.outputs.connection-uri }}" | base64
tests/fixtures/initdb.sh
env:
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
PGSERVICE: ${{ steps.pg.outputs.service-name }}
- name: Download build artifact build-${{ matrix.target }}
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -534,13 +451,12 @@ jobs:
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: Start HTTP Server
run: |
docker run --rm -d \
--name fileserver \
-p 5412:80 \
-v ${{ github.workspace }}/tests/fixtures/pmtiles2:/usr/share/nginx/html \
nginx:alpine
- name: Run NGINX
uses: nyurik/[email protected]
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Init database
run: tests/fixtures/initdb.sh
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/grcov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-11-03
toolchain: nightly-2024-05-24
override: true

- name: Cleanup GCDA files
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/initdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
FIXTURES_DIR="$(dirname "$0")"
echo -e "\n\n\n"
echo "################################################################################################"
echo "Loading Martin test fixtures into '$PGDATABASE' as user '$PGUSER'"
echo "Loading Martin test fixtures into '${DATABASE_URL:-${PGDATABASE:-(local db)}}'"
echo "################################################################################################"


Expand All @@ -16,7 +16,7 @@ psql -P pager=off -v ON_ERROR_STOP=1 -t -c "select PostGIS_Full_Version();"

# On error, make sure do delete all the tables we created
# TODO: see if we can have a fail-early service test to detect errors
trap 'echo -e "\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!\n\nDELETING DB $PGDATABASE DUE TO AN ERROR!\n\n\n" && psql -c "DROP SCHEMA IF EXISTS "MixedCase" CASCADE; DROP SCHEMA IF EXISTS autodetect CASCADE;"' ERR
trap 'echo -e "\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!\n\nDropping schemas DUE TO AN ERROR!\n\n\n" && psql -c "DROP SCHEMA IF EXISTS "MixedCase" CASCADE; DROP SCHEMA IF EXISTS autodetect CASCADE;"' ERR

echo -e "\n\n\n"
echo "################################################################################################"
Expand Down

0 comments on commit d77533f

Please sign in to comment.