62558e1c7f
* add dev-env tests Co-authored-by: alberhander <albertoh@carto.com>
138 lines
4.4 KiB
YAML
138 lines
4.4 KiB
YAML
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'LICENSE'
|
|
- 'README**'
|
|
- 'HOW_TO_RELEASE**'
|
|
- 'LOGGING**'
|
|
|
|
env:
|
|
GCLOUD_VERSION: '306.0.0'
|
|
ARTIFACTS_PROJECT_ID: cartodb-on-gcp-main-artifacts
|
|
NODE_VERSION: '12.18.3'
|
|
_DOCKER_IMAGE_TO_REPLACE: 'sql-api'
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-18.04
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: true
|
|
token: ${{ secrets.CARTOFANTE_PERSONAL_TOKEN }}
|
|
|
|
- name: Setup gcloud authentication
|
|
uses: google-github-actions/setup-gcloud@master
|
|
with:
|
|
version: ${{env.GCLOUD_VERSION}}
|
|
service_account_key: ${{ secrets.ARTIFACTS_GCLOUD_ACCOUNT_BASE64 }}
|
|
|
|
- name: Configure docker and pull images
|
|
run: |
|
|
gcloud auth configure-docker
|
|
docker pull gcr.io/cartodb-on-gcp-main-artifacts/postgres:latest
|
|
docker pull gcr.io/cartodb-on-gcp-main-artifacts/redis:latest
|
|
|
|
- name: Run deps (Redis and Postgres)
|
|
run: |
|
|
docker run --rm -d --name postgres -p 5432:5432 gcr.io/cartodb-on-gcp-main-artifacts/postgres:latest
|
|
docker run --rm -d --name redis -p 6379:6379 gcr.io/cartodb-on-gcp-main-artifacts/redis:latest
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: ${{env.NODE_VERSION}}
|
|
|
|
- run: npm ci
|
|
|
|
- name: install redis tools
|
|
run: sudo apt-get -yqq install redis-tools gdal-bin
|
|
|
|
- run: npm test
|
|
env:
|
|
CI: true
|
|
CARTO_SQL_API_ENV_BASED_CONF: true
|
|
CARTO_SQL_API_POSTGRES_HOST: localhost
|
|
CARTO_SQL_API_POSTGRES_PORT: 5432
|
|
CARTO_SQL_API_REDIS_HOST: localhost
|
|
CARTO_SQL_API_REDIS_PORT: 6379
|
|
CARTO_SQL_API_NODE_ENV: test
|
|
NODE_ENV: test
|
|
|
|
- name: Stop deps (Redis and Postgres)
|
|
run: |
|
|
docker stop postgres redis
|
|
|
|
dev-env-tests:
|
|
runs-on: ubuntu-18.04
|
|
timeout-minutes: 15
|
|
needs: build-and-test
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: true
|
|
token: ${{ secrets.CARTOFANTE_PERSONAL_TOKEN }}
|
|
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
repository: 'cartodb/docker-dev-env'
|
|
path: 'docker-dev-env'
|
|
token: ${{ secrets.CARTOFANTE_PERSONAL_TOKEN }}
|
|
|
|
- name: Check docker-compose syntax
|
|
run: |
|
|
set -ex
|
|
BRANCH_NAME=${GITHUB_HEAD_REF#refs/heads/}
|
|
BRANCH_NAME=${BRANCH_NAME//\//-}
|
|
cp -r docker-dev-env/* .
|
|
cp -f docker-dev-env/.env.sample .env
|
|
sed -i 's@'"${{env._DOCKER_IMAGE_TO_REPLACE}}":latest'@'"${{env._DOCKER_IMAGE_TO_REPLACE}}":"${BRANCH_NAME}"'@' .env
|
|
cat .env | grep 'IMAGE'
|
|
docker-compose config
|
|
|
|
- name: Build image
|
|
run: |
|
|
BRANCH_NAME=${GITHUB_HEAD_REF#refs/heads/}
|
|
BRANCH_NAME=${BRANCH_NAME//\//-}
|
|
echo "Building sql-api image from branch: $BRANCH_NAME, commit: ${GITHUB_SHA::7}..."
|
|
docker build -f private/Dockerfile --label="org.opencontainers.image.created=$(date --rfc-3339=seconds)" --label=org.opencontainers.image.revision=${GITHUB_SHA} -t gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${BRANCH_NAME} -t gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${GITHUB_SHA::7} -t gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${BRANCH_NAME}--${GITHUB_SHA::7} .
|
|
|
|
- name: Set up gcloud I
|
|
uses: google-github-actions/setup-gcloud@master
|
|
with:
|
|
service_account_key: ${{ secrets.ARTIFACTS_GCLOUD_ACCOUNT_BASE64 }}
|
|
export_default_credentials: true
|
|
version: '297.0.1' # https://github.com/google-github-actions/setup-gcloud/issues/128
|
|
|
|
- name: Set up gcloud II
|
|
run: |
|
|
gcloud auth configure-docker
|
|
|
|
- name: Basic environment init
|
|
run: |
|
|
./scripts/init.sh
|
|
|
|
- name: Test networking
|
|
run: |
|
|
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test-networking
|
|
|
|
- name: Test DB seed
|
|
run: |
|
|
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test-db
|
|
|
|
- name: Push image
|
|
run: |
|
|
BRANCH_NAME=${GITHUB_HEAD_REF#refs/heads/}
|
|
BRANCH_NAME=${BRANCH_NAME//\//-}
|
|
|
|
echo 'Pushing images to the registry...'
|
|
docker push gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${BRANCH_NAME}
|
|
docker push gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${GITHUB_SHA::7}
|
|
docker push gcr.io/$ARTIFACTS_PROJECT_ID/sql-api:${BRANCH_NAME}--${GITHUB_SHA::7}
|
|
|
|
|