Skip to content

Commit

Permalink
Create reusable GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-antoniak committed Oct 29, 2024
1 parent 60a2022 commit abb1a71
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
51 changes: 2 additions & 49 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
pull_request:
types: [ opened, synchronize, reopened ]

env:
CCM_VERSION: "6e71061146f7ae67b84ccd2b1d90d7319b640e4c"

jobs:
build:
name: Unit tests
Expand Down Expand Up @@ -51,29 +48,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Java
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
echo "sdkman_auto_answer=true" >> ~/.sdkman/etc/config
# sdk list java
sdk install java 11.0.24-zulu
echo "JAVA11_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
sdk install java 17.0.12-zulu
echo "JAVA17_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
# by default use JDK 11
sdk default java 11.0.24-zulu
sdk use java 11.0.24-zulu
echo "JAVA_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Install CCM
run: |
python3 -m venv ~/venv
~/venv/bin/pip install setuptools
~/venv/bin/pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
- uses: ./.github/workflows/setup-environment
- name: Start cassandra nodes
run: |
source ~/venv/bin/activate
Expand Down Expand Up @@ -158,29 +133,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Install Java
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
echo "sdkman_auto_answer=true" >> ~/.sdkman/etc/config
# sdk list java
sdk install java 11.0.24-zulu
echo "JAVA11_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
sdk install java 17.0.12-zulu
echo "JAVA17_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
# by default use JDK 11
sdk default java 11.0.24-zulu
sdk use java 11.0.24-zulu
echo "JAVA_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Install CCM
run: |
python3 -m venv ~/venv
~/venv/bin/pip install setuptools
~/venv/bin/pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
- uses: ./.github/workflows/setup-environment
- name: Start cassandra nodes
run: |
source ~/venv/bin/activate
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/setup-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
on:
workflow_call:

env:
CCM_VERSION: "6e71061146f7ae67b84ccd2b1d90d7319b640e4c"

jobs:
setup-environment:
name: Setup Integration Tests Environment
runs-on: ubuntu-latest
steps:
- name: Set up cache for SDKMAN
uses: actions/cache@v3
with:
path: ~/.sdkman
key: ${{ runner.os }}-sdkman

- name: Set up cache for pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Java
run: |
echo "Installing SDKMAN..."
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
echo "sdkman_auto_answer=true" >> ~/.sdkman/etc/config
echo "Installing Java versions..."
sdk install java 11.0.24-zulu
sdk install java 17.0.12-zulu
sdk default java 11.0.24-zulu
sdk use java 11.0.24-zulu
echo "JAVA11_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
echo "JAVA17_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
echo "JAVA_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Install CCM
run: |
echo "Creating Python virtual environment..."
VENV_DIR="$HOME/venv"
python3 -m venv $VENV_DIR
source $VENV_DIR/bin/activate
pip install --upgrade pip setuptools
echo "Installing CCM..."
pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"

0 comments on commit abb1a71

Please sign in to comment.