Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
apodlaski committed Oct 31, 2024
1 parent b02b26f commit 5267b0e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 110 deletions.
97 changes: 52 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -54,44 +46,65 @@ jobs:
OBAN_LICENSE_KEY: ${{ secrets.OBAN_LICENSE_KEY }}

steps:
- name: Set up Elixir
id: beam
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}

- name: Install ExEnv
run: mix archive.install hex ex_env 0.3.2 --force

- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: recursive
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}

- name: Init Deps Cache
# When following job fails, it means you've changed .tool-versions
# and you must trigger machine.yml (build machine) workflow to build correct machine-cache
- name: Restore elixir and erlang
uses: actions/cache/restore@v3
id: deps-cache
id: machine-cache
with:
key: v2-release-${{ hashFiles(format('{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
key: v2-release-${{ runner.os }}-amd64-${{ hashFiles('./.tool-versions') }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
~/.asdf
- name: Init Code Cache
uses: actions/cache/restore@v3
id: code-cache
- name: Install Erlang, Elixir, etc
- uses: asdf-vm/actions/install@v2

- name: Install mix & hex and ex_env
if: steps.machine-cache.outputs.cache-hit != 'true'
run: |
mix local.hex --force
mix local.rebar --force
mix archive.install --force hex ex_env 0.3.2 --force
- name: Add coingaming organization
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.organization auth coingaming --key ${{secrets.HEX_ORGANIZATION_COINGAMING_KEY}}
- name: Add oban repo
if: steps.deps-cache.outputs.cache-hit != 'true' && env.OBAN_FINGERPRINT
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.repo add oban https://getoban.pro/repo --fetch-public-key ${{env.OBAN_FINGERPRINT}} --auth-key ${{env.OBAN_LICENSE_KEY}}
- name: Save elixir and erlang
if: steps.machine-cache.outputs.cache-hit != 'true'
uses: buildjet/cache/save@v3
id: machine-cache-save
with:
key: v2-release-${{ github.sha }}-${{ inputs.mix-env }}
key: v2-release-${{ runner.os }}-amd64-${{ hashFiles('./.tool-versions') }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
~/.asdf
- name: Restore Deps Cache
uses: actions/cache/restore@v3
id: deps-cache
with:
key: v2-release-${{ hashFiles(format('{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
Expand All @@ -101,21 +114,19 @@ jobs:
ssh-private-key: |
${{ secrets.SSH_KEYS }}
- name: Init Code Cache
uses: actions/cache/restore@v3
id: code-cache
with:
key: v2-release-${{ github.sha }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
- name: Install protoc
run: sudo apt-get install protobuf-compiler

- name: Add coingaming organization
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.organization auth coingaming --key ${{secrets.HEX_ORGANIZATION_COINGAMING_KEY}}
- name: Add oban repo
if: steps.deps-cache.outputs.cache-hit != 'true' && env.OBAN_FINGERPRINT
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.repo add oban https://getoban.pro/repo --fetch-public-key ${{env.OBAN_FINGERPRINT}} --auth-key ${{env.OBAN_LICENSE_KEY}}
- name: Authorize github.com
env:
GH_PAT: ${{ secrets.GH_TOKEN }}
Expand Down Expand Up @@ -157,8 +168,6 @@ jobs:
key: v2-release-${{ hashFiles(format('{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
Expand All @@ -175,7 +184,5 @@ jobs:
key: v2-release-${{ github.sha }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
24 changes: 7 additions & 17 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -52,20 +44,14 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}


code_checks:
name: Run code checks
needs: build
runs-on: ubuntu-20.04

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Get workflow version
id: workflow-version
uses: canonical/get-workflow-version-action@v1
Expand All @@ -74,17 +60,21 @@ jobs:
file-name: code-checks.yml
github-token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}

- name: Checkout private tools
uses: actions/checkout@v4
with:
repository: coingaming/.github
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
path: my-tools

- name: Prepare repo and env
uses: coingaming/.github/actions/prepare@${{ steps.workflow-version.outputs.sha }}
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
elixir-code-path: ${{ inputs.elixir-code-path }}


- name: Install protoc
run: sudo apt-get install protobuf-compiler

Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/dialyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -41,8 +33,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}

dialyzer:
Expand All @@ -56,8 +46,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
elixir-code-path: ${{ inputs.elixir-code-path }}

Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/release-hex-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -45,8 +37,6 @@ jobs:
ref: ${{ inputs.version }}
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}

release:
Expand All @@ -65,8 +55,6 @@ jobs:
ref: ${{ inputs.version }}
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
elixir-code-path: ${{ inputs.elixir-code-path }}

Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/release-hex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -41,8 +33,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}

release:
Expand All @@ -59,8 +49,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}

Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ on:
type: string
required: false
default: ""
elixir-version:
type: string
required: false
default: "1.14.3" # Define the elixir version
otp-version:
type: string
required: false
default: "25.1" # Define the OTP version
mix-env:
type: string
required: false
Expand Down Expand Up @@ -49,8 +41,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
elixir-code-path: ${{ inputs.elixir-code-path }}

tests:
Expand Down Expand Up @@ -80,8 +70,6 @@ jobs:
with:
mix-env: ${{ inputs.mix-env }}
cache_paths: ${{ inputs.cache_paths }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
elixir-code-path: ${{ inputs.elixir-code-path }}

Expand Down

0 comments on commit 5267b0e

Please sign in to comment.