Revision Control
Causal is integrated with your revision control system so FDL changes automatically trigger updates to the data warehouse and tools UI. The following sections illustrate how to do this.
Github Actions
The examples in our examples repository use Github Actions in order to send FDL updates to Causal.
The actions file illustrates how to send your FDL file to Causal on a new commit. It simply grabs the FDL file from the newly checked in version and pushes it to the Causal endpoint.
See the next section if your setup uses more than one FDL file.
Copy this file into your repo under .github/workflows/causal-actions.yml
and update the file to contain the credentials you received in Backend Setup:
- replace
GITHUB_OWNER
with the owner of the repository. - replace
GITHUB_REPO
with the name of your repository - replace
ENV_ID
with the your getting started environment id
You'll notice that the YAML file uses a secret (secrets.CAUSAL_TOKEN
). This is the token we sent back to you from the previous chapter. Go ahead and add the secret to your repository by going to Settings, Secrets, and selecting New repository secret:
Save the file and push the code to your repository:
## commit the changes to the actions file
$ git add .github/workflows/causal-actions.yml
$ git commit -m "Add my info"
$ git push -u origin main
You should be able to go to the "Actions" tab in your repo and see the action pushing the FDL file to Causal. After that, you'll be able to see your new feature in the tools user interface.
Gitlab CI/CD
You can use gitlab CI/CD in order to synchronize your FDL with Causal. The following .gitlab-ci.yml
file handles pushing FDL in our own demo application:
stages:
- deploy
fdl-deploy:
stage: deploy
script:
- 'wget --content-on-error -O- --header=Content-Type:text/plain --post-file demo.fdl "https://tools.causallabs.io/fdlpush?token=$CAUSAL_DEV_TOKEN&env=4aeb0ef1-f8ee-4051-b2a3-328e7371eda5"'
environment: development
only:
- development
It simply waits for a commit to the development branch. During the deploy to the development environment, the FDL file 'demo.fdl' is pushed to the appropriate endpoint with Causal credentials and the correct environment ID.
The credentials are stored in a CI/CD variable (Settings > CI/CD > Variables) in order to keep them secure:
Push to Endpoint
You may setup integration with Causal using any CI/CD platfrom you'd like by pushing the changed FDL file to Causal on a commit.
The compiler has a --push-fdl
option that can take your FDL files and update the server. If your project contains multiple FDL files that's the current way to handle that:
## replace TOKEN and ENV_ID with the credentials you got from Causal
$ npx causalc --push-fdl --token TOKEN --environment ENV_ID file1.fdl file2.fdl etc.fdl
The --push-fdl
option will compile your FDL and then send it up to Causal. The compiler may return an error (for example, if the FDL file you are sending has a compile error). If not, you should be able to go into the tools user interface and see your feature definitions.
If you have a single file FDL install, you can simply POST the file to the Causal HTTPS endpoint:
## replace TOKEN and ENV_ID with the credentials you got from Causal
$ wget --content-on-error -O- --header='Content-Type:text/plain' --post-file file1.fdl \
'https://tools.causallabs.io/fdlpush?token=SECURE_TOKEN&env=ENV_ID'
Where SECURE_TOKEN and ENV_ID are the credentials you received in Backend Setup.