GitHub Actions banner

Automate tasks, such as running unit tests or lint code, whenever code is committed to a GitHub repository.

GitHub Actions can run one or more tasks after specific events, such as commits, raising issues or pull requests.

An event triggers a configured workflow which contains one or more jobs. A job contains a one or more steps which defines actions to run.

Term Description
Event Triggers a workflow, e.g. Create pull request, push commit, etc.
Workflow Tope level configuration containing one or more jobs, triggered by a specific event
Job Set of steps executed in the same runner, multiple jobs execute in parallel within their own instance of a runner
Step Individual task that runs commands (actions), sharing data with other steps
Action Standalone commands defined within a step, custom commands or GitHub community
Runner A GitHub Actions server, listening for available jobs

Example GitHub Action

.github/workflows/workflow-name.yaml is a file that contains the workflow definition.

Setup Java adds an OpenJDK distribution, i.e. Eclipse Temurin, at a specified version (Java 17 recommended).

Setup Clojure provides Clojure via Clojure CLI, Leiningen or Boot. Clojure CLI is recommended.

Cache is used to cache Clojure and Java libraries (dependencies or 'deps').

The example workflow runs on Ubuntu.

The project code is checked out from the Git repository.

Java and Clojure are added to the environment

Unit tests are run using the :test/run alias (this alias should run Kaocha or similar test runner)

The Clojure project is packaged into an Uberjar for deployment

name: Test and Package project
on: [push]
jobs:
  clojure:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Cache Clojure Dependencies
        uses: actions/cache@v3
        with:
          path:
            - ~/.m2
            - ~/.gitlibs
          key: cache-${{ hashFiles('**/deps.edn') }}

      - name: Prepare java
        uses: actions/setup-java@v3.5.1
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: Install clojure tools
        uses: DeLaGuardo/setup-clojure@9.5
        with:
          cli: 1.11.1.1165    # Clojure CLI based on tools.deps

      - name: Run Unit tests
        run: clojure -X:test/run

      - name: Package Clojure project
        run: clojure -X:project/uberjar

References

results matching ""

    No results matching ""