This document attempts to provide a high-level overview of continuous integration at Kalamuna. We generally aim to provide Linting, Compilation, and Visual Regression testing, as well as the obvious like pushing the code to a remote.
CI
Kalamuna leverages Github Actions for the bulk of its new build. Historically, we’ve also satisfied the needs of projects with Circle CI in the past.
Our default drupal project contains examples with which we copy & paste for new projects. It has some pretty basic steps, but for the most part it is in charge of pushing to Pantheon or any other remote.
name: Build and Deploy on: push: branches: - '*' jobs: build-and-deploy: runs-on: ubuntu-latest steps: # Check out the codebase from github. - uses: actions/checkout@v3 with: persist-credentials: false fetch-depth: 0 - name: Reconfigure git to use HTTP authentication run: > git config --global url."https://github.com/".insteadOf ssh://git@github.com/ # Update system packages and add dependencies. - run: sudo apt-get update -y - run: sudo apt-get install -y libpng-dev # Prepare .gitignore - run: rm .gitignore; mv .gitignore-deploy .gitignore # Install node modules and build theme. - run: cd web/themes/custom/simplytheme && npm install && npm run build # Install PhpCS - name: Install PhpCS uses: shivammathur/setup-php@v2 with: php-version: "7.4" coverage: none tools: phpcs # Lint the Project. - name: Run Linters uses: wearerequired/lint-action@v2 with: eslint_dir: web/themes/custom/simplytheme eslint: true php_codesniffer: true stylelint_dir: web/themes/custom/simplytheme stylelint: true # Commit the assembled code to git in preparation for depoyment. - run: git config --global user.name "Kala C. Bot" - run: git config --global user.email "kalacommitbot@kalamuna.com" - run: find web -type d -name .git -print0|xargs -0 rm -rf - run: git add . - run: "git commit -m \"Built ${{ github.event.repository.name }}/${{ github.head_ref || github.ref_name }} from: ${{ github.sha }} All code changes should be committed to: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }} Any commits made directly to this Pantheon repository will be overwritten.\"" # Push the assembled code to the Pantheon repo specified in the circle project environment variables. - run: mkdir -p ~/.ssh/ - name: Create SSH key run: | mkdir -p ~/.ssh/ echo "$SSH_PRIVATE_KEY" > ~/.ssh/private.key sudo chmod 600 ~/.ssh/private.key echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts shell: bash env: SSH_PRIVATE_KEY: ${{secrets.PANTHEON_SSH_KEY}} SSH_KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} SSH_KEY_PATH: ${{ github.workspace }}/.ssh/private.key - run: echo -e "Host *drush.in\n\tStrictHostKeyChecking no" >> ~/.ssh/config - run: echo -e "\tIdentityFile ~/.ssh/private.key\n" >> ~/.ssh/config - run: cat ~/.ssh/config - run: cat ~/.ssh/known_hosts - run: git remote add pantheon ${{ secrets.PANTHEON_REPO }} - run: git push --force pantheon ${{ github.head_ref || github.ref_name }}
To enable pushing to a given remote, you will need to register secrets within the git repo such that it can inject those into the workflow. Checkout this documentation for more info as to how to add the bits that are required to make the script work.
All that should be required for Github Actions configuration is to copy that file (check the repo for more context) and adding environment variables!
Linting
We aim to lint our project against a set of standards to create a replicable code look and feel. The CI will give feedback on each push to the user in Github without blocking deployment.
Visual Regression Testing
By default, regression testing is triggered when a user pushes to the vrt
branch associated with a repo. This triggers an event with our Percy integration.