From 3df073657a0f55728aedaf33825ac200cf78b9e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jul 2024 18:39:08 +0530 Subject: [PATCH] Added GitHub Actions workflow to check format and run tests --- .github/workflows/check-format-and-test.yml | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/check-format-and-test.yml diff --git a/.github/workflows/check-format-and-test.yml b/.github/workflows/check-format-and-test.yml new file mode 100644 index 0000000..c3609d0 --- /dev/null +++ b/.github/workflows/check-format-and-test.yml @@ -0,0 +1,37 @@ +name: Check Format and Run Tests + +on: + pull_request: + paths: + - '**/*.ex' + - '**/*.exs' + - 'mix.exs' + - '.formatter.exs' + +jobs: + format-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Elixir + uses: erlef/setup-elixir@v2 + with: + elixir-version: '1.14' + otp-version: '25' + + - name: Install dependencies + run: mix deps.get + + - name: Check code formatting + run: | + mix format --check-formatted + if [ $? -ne 0 ]; then + echo "Code is not formatted correctly. Please run 'mix format' and commit your changes." + exit 1 + fi + + - name: Run tests + run: mix test