From 9c48a0537d810de4994ba4b3765916dacca79fa0 Mon Sep 17 00:00:00 2001 From: Piotr Przetacznik Date: Thu, 28 Mar 2024 16:58:52 +0100 Subject: [PATCH] chore: Move ielixir build to separate workflow --- .github/workflows/build_workflow.yml | 68 ++++++++++++++++++++++++++ .github/workflows/docker_workflow.yml | 6 +-- .github/workflows/docs_workflow.yml | 62 +++++++++++++++-------- .github/workflows/elixir.yml | 62 +++++------------------ .github/workflows/generate_version.yml | 4 -- .github/workflows/release.yml | 38 +------------- 6 files changed, 124 insertions(+), 116 deletions(-) create mode 100644 .github/workflows/build_workflow.yml diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml new file mode 100644 index 0000000..75eb38f --- /dev/null +++ b/.github/workflows/build_workflow.yml @@ -0,0 +1,68 @@ +name: IElixir build and test + +on: + workflow_call: + inputs: + version: + required: true + type: string + build_version: + required: true + type: string + is_release: + required: true + type: string + +jobs: + build: + name: Build and test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-22.04'] + elixir-version: ['1.14'] + otp-version: ['26'] + python-version: ['3.8', '3.12'] + steps: + - name: Checkout IElixir project + uses: actions/checkout@v2 + - name: Set version + if: inputs.is_release == 'true' + run: | + echo ${{ inputs.version }} > VERSION + - name: Set build version + if: inputs.is_release == 'false' + run: | + echo ${{ inputs.build_version }} > VERSION + - name: Install prerequisites + run: | + sudo apt install -y openssl libncurses5 + sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: 'OTP-${{ matrix.otp-version }}' + elixir-version: 'v${{ matrix.elixir-version }}-otp-${{ matrix.otp-version }}' + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install python packages + run: | + pip install pip --upgrade + pip install -r jupyter_kernel_test/requirements.txt + - name: Restore dependencies cache + uses: actions/cache@v2 + with: + path: deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + - name: Compile IElixir and install + run: | + mix deps.get + mix deps.compile + MIX_ENV=dev ./install_script.sh + - name: Run tests + run: | + mix test + MIX_ENV=dev python jupyter_kernel_test/test_ielixir.py diff --git a/.github/workflows/docker_workflow.yml b/.github/workflows/docker_workflow.yml index cc14a38..c6cc6e8 100644 --- a/.github/workflows/docker_workflow.yml +++ b/.github/workflows/docker_workflow.yml @@ -13,14 +13,12 @@ on: required: true jobs: - main: + build_docker: + name: Building docker images runs-on: ubuntu-latest steps: - name: Checkout IElixir project uses: actions/checkout@v2 - - name: Set version - run: | - echo ${{ inputs.version }} >> VERSION - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/.github/workflows/docs_workflow.yml b/.github/workflows/docs_workflow.yml index 214ef03..2a077f5 100644 --- a/.github/workflows/docs_workflow.yml +++ b/.github/workflows/docs_workflow.yml @@ -6,9 +6,17 @@ on: version: required: true type: string + build_version: + required: true + type: string + is_release: + required: true + type: string secrets: GH_TOKEN: required: true + HEX_API_KEY: + required: true jobs: docs: @@ -16,25 +24,37 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} steps: - - name: Checkout IElixir project - uses: actions/checkout@v2 - - name: Set version - run: | - echo ${{ inputs.version }} > VERSION - - name: Install prerequisites - run: | - sudo apt install -y openssl libncurses5 - sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev - - name: Set up Elixir - uses: erlef/setup-beam@v1 - with: - otp-version: 'OTP-26.0' - elixir-version: 'v1.14-otp-26' - - name: Generate documentation - run: | - MIX_ENV=docs mix deps.get - MIX_ENV=docs mix compile - MIX_ENV=docs mix docs - MIX_ENV=docs mix inch.report - MIX_ENV=test mix coveralls.github + - name: Checkout IElixir project + uses: actions/checkout@v2 + - name: Set version + if: inputs.is_release == 'true' + run: | + echo ${{ inputs.version }} > VERSION + - name: Set build version + if: inputs.is_release == 'false' + run: | + echo ${{ inputs.build_version }} > VERSION + - name: Install prerequisites + run: | + sudo apt install -y openssl libncurses5 + sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: 'OTP-26.0' + elixir-version: 'v1.14-otp-26' + - name: Generate documentation + run: | + MIX_ENV=docs mix deps.get + MIX_ENV=docs mix compile + MIX_ENV=docs mix docs + MIX_ENV=docs mix inch.report + MIX_ENV=test mix coveralls.github + - name: Publish documentation + if: inputs.is_release == 'true' + run: | + mix hex.config api_key $HEX_API_KEY + mix hex.publish package --yes + MIX_ENV=docs mix hex.publish docs diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 026384d..8bfd2d1 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -13,68 +13,30 @@ jobs: generate_version: uses: ./.github/workflows/generate_version.yml + build_ielixir: + uses: ./.github/workflows/build_workflow.yml + needs: generate_version + with: + version: ${{ needs.generate_version.outputs.version }} + build_version: ${{ needs.generate_version.outputs.build_version }} + is_release: ${{ needs.generate_version.outputs.is_release }} + build_docker: uses: ./.github/workflows/docker_workflow.yml - needs: generate_version + needs: [generate_version, build_ielixir] with: version: ${{ needs.generate_version.outputs.version }} secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - build: - name: Build and test - runs-on: ${{ matrix.os }} - needs: generate_version - strategy: - matrix: - os: [ubuntu-22.04] - elixir-version: ['1.14'] - otp-version: ['26'] - python-version: ['3.8', '3.12'] - steps: - - name: Checkout IElixir project - uses: actions/checkout@v2 - - name: Set version - run: | - echo ${{ needs.generate_version.outputs.build_version }} > VERSION - - name: Install prerequisites - run: | - sudo apt install -y openssl libncurses5 - sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev - - name: Set up Elixir - uses: erlef/setup-beam@v1 - with: - otp-version: 'OTP-${{ matrix.otp-version }}' - elixir-version: 'v${{ matrix.elixir-version }}-otp-${{ matrix.otp-version }}' - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install python packages - run: | - pip install pip --upgrade - pip install -r jupyter_kernel_test/requirements.txt - - name: Restore dependencies cache - uses: actions/cache@v2 - with: - path: deps - key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- - - name: Compile IElixir and install - run: | - mix deps.get - mix deps.compile - MIX_ENV=dev ./install_script.sh - - name: Run tests - run: | - mix test - MIX_ENV=dev python jupyter_kernel_test/test_ielixir.py - docs: uses: ./.github/workflows/docs_workflow.yml needs: generate_version with: version: ${{ needs.generate_version.outputs.version }} + build_version: ${{ needs.generate_version.outputs.build_version }} + is_release: ${{ needs.generate_version.outputs.is_release }} secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} diff --git a/.github/workflows/generate_version.yml b/.github/workflows/generate_version.yml index 544223b..db62381 100644 --- a/.github/workflows/generate_version.yml +++ b/.github/workflows/generate_version.yml @@ -34,8 +34,4 @@ jobs: run: | echo "${{ github.ref }}" echo "IELIXIR_IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_OUTPUT - - name: Print flags - run: | - cat $GITHUB_OUTPUT - echo $GITHUB_OUTPUT diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ccb3efc..a052ae0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,50 +4,14 @@ on: push: tags: - 'v*' - pull_request: - branches: - - 'feature/**' jobs: - generate_version: - uses: ./.github/workflows/generate_version.yml - release: - name: Documentation and coverage reports + name: Create a release runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} steps: - - name: Checkout IElixir project - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Set version - run: | - echo ${{ needs.generate_version.outputs.version }} > VERSION - python -c 'import sys; a, b, c = sys.stdin.read().strip().split("."); print(f"{a}.{b}.{int(c)+1}")' < VERSION > VERSION - - name: Install prerequisites - run: | - sudo apt install -y openssl libncurses5 - sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev - - name: Set up Elixir - uses: erlef/setup-beam@v1 - with: - otp-version: 'OTP-${{ matrix.otp-version }}' - elixir-version: 'v${{ matrix.elixir-version }}-otp-${{ matrix.otp-version }}' - - name: Generate documentation - run: | - MIX_ENV=docs mix deps.get - MIX_ENV=docs mix compile - MIX_ENV=docs mix docs - MIX_ENV=docs mix inch.report - MIX_ENV=test mix coveralls.github - mix hex.config api_key $HEX_API_KEY - mix hex.publish package --yes - MIX_ENV=docs mix hex.publish docs - name: Create Release id: create_release uses: actions/create-release@v1