-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathconfig.yml
149 lines (127 loc) · 5.63 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Python CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-python/ for more details
version: 2.1
jobs:
build:
docker:
# CircleCI maintains a library of pre-built images documented at
# https://circleci.com/developer/images
# use `-browsers` prefix for selenium tests, e.g. `<image_name>-browsers`
# Python
- image: cimg/python:3.11
environment:
TZ: America/New_York
SQLA_TEST_CONN: postgresql://postgres@0.0.0.0/cfdm_unit_test
# PostgreSQL
- image: cimg/postgres:13.5
environment:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: cfdm_unit_test
# elasticsearch
- image: docker.elastic.co/elasticsearch/elasticsearch:7.4.0
environment:
cluster.name: elasticsearch
xpack.security.enabled: false
transport.host: localhost
network.host: 127.0.0.1
http.port: 9200
discovery.type: single-node
steps:
- checkout
- run:
name: Install system dependencies
# Commands listed here are from the CircleCI PostgreSQL config docs:
# https://circleci.com/docs/2.0/postgres-config/#postgresql-circleci-configuration-example
command: |
sudo apt-get --allow-releaseinfo-change-suite update -qq && sudo apt-get install -y build-essential postgresql-client
echo 'export PATH=/usr/lib/postgresql/13.5/bin/:$PATH' >> $BASH_ENV
- run:
name: Install flyway
command: |
sudo apt-get --allow-releaseinfo-change-suite update && sudo apt-get install -y default-jdk
mkdir flyway
curl -s https://repo.maven.apache.org/maven2/org/flywaydb/flyway-commandline/11.0.0/flyway-commandline-11.0.0-linux-x64.tar.gz | tar zxv -C flyway
echo 'export PATH=./flyway/flyway-11.0.0:$PATH' >> $BASH_ENV
- restore_cache:
keys:
- v2-fec-api-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v2-fec-api-dependencies-
- run:
name: Install node dependencies
command: |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
echo ". ~/.nvm/nvm.sh" >> $BASH_ENV
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 22.1.0
nvm use 22.1.0
nvm alias default 22.1.0
npm install
npm run build
- run:
name: Install Python dependencies
command: |
sudo rm -rf .env
python3 -m venv .env
. .env/bin/activate
pip install -r requirements.txt
- save_cache:
paths:
- ./.env
- ./node_modules
key: v2-fec-api-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "package.json" }}
- run:
name: Ensure database is available
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Wait for Elasticsearch
command: dockerize -wait http://localhost:9200 -timeout 1m
- run:
name: Run tests
command: |
. .env/bin/activate
pytest
- run:
name: Run pre-commit
command: |
. .env/bin/activate
pre-commit run --all-files
- run:
name: Upload coverage report to codecov
command: |
. .env/bin/activate
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -v
- store_artifacts:
path: test-reports
destination: test-reports
- run:
name: Install cf cli
command: |
mkdir -p $HOME/bin
export PATH=$HOME/bin:$PATH
curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&version=8.9.0" | tar xzv -C $HOME/bin
- add_ssh_keys # add Bastion host private keys configured in the UI
- run: echo $FEC_BASTION_HOST_PUBLIC_KEY >> ~/.ssh/known_hosts # copy Bastion host public key
- run: $FEC_BASTION_DEV_TUNNEL # establsh tunnel/port mapping to 'dev' RDS from CircleCI container through Bastion host.
- run: $FEC_BASTION_STAGE_TUNNEL # establsh tunnel/port mapping to 'stage' RDS from CircleCI container through Bastion host.
- run: $FEC_BASTION_PROD_TUNNEL # establsh tunnel/port mapping to 'prod' RDS from CircleCI container through Bastion host.
- run:
name: Deploy API
command: |
export PATH=$HOME/bin:$PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
. .env/bin/activate
nvm use default
invoke deploy --branch $CIRCLE_BRANCH --login True --yes --migrate-database