This guide provides instructions for setting up continuous integration (CI) and refactoring validation workflows for the project. It also outlines best practices for handling sensitive credentials when working with Docker.
- Ensure you have Docker installed on your local machine.
- Ensure you have a Google Cloud Platform (GCP) service account key saved as
.gee-sa-priv-key.json
.
For security reasons, avoid embedding Google Earth Engine service account credentials in the Docker image. Instead, mount the credentials file from your local machine into the Docker container at runtime. This ensures that the credentials stay on your local machine and aren't embedded into the image.
-
Local Machine:
- Make sure the
.gee-sa-priv-key.json
file is saved on your local machine.
- Make sure the
-
Docker Run Command:
- Use the
docker run
command with the-v
option to mount the credentials file into the container.
docker run -v $(pwd)/.gee-sa-priv-key.json:/app/.gee-sa-priv-key.json my-image
- Use the
In the above command:
-v $(pwd)/.gee-sa-priv-key.json:/app/.gee-sa-priv-key.json
mounts the.gee-sa-priv-key.json
file from your current directory ($(pwd)
) to/app/.gee-sa-priv-key.json
inside the container.my-image
is the name of your Docker image.
The application inside the Docker container can now access the .gee-sa-priv-key.json
file at /app/.gee-sa-priv-key.json
.
The CI workflow (ci.yml
) ensures that the code quality meets the standards. It runs on every push and pull request.
Steps in the workflow include:
- Checkout the code from the repository.
- Set up the desired Python version.
- Cache Python dependencies to speed up future runs.
- Install project dependencies and linting tools.
- Lint the code using
flake8
. - Check code formatting with
black
.
To view the complete CI configuration, refer to the ci.yml
file.
The Refactoring Validation workflow (refactoring_validation.yml
) validates refactoring by comparing the outputs of the original library and the current library using Docker containers. This workflow runs on pushes to the main
branch and is scheduled to run weekly.
Steps in the workflow include:
- Checkout the code from the repository.
- Set up GCP credentials from GitHub secrets.
- Create directories for downloads.
- Build and run the original library Docker container.
- Build and run the current library Docker container.
- Install necessary Python dependencies.
- Compare the results using the provided comparison script.
To view the complete Refactoring Validation configuration, refer to the refactoring_validation.yml
file.