diff --git a/.github/scripts/activate.sh b/.github/scripts/activate.sh new file mode 100755 index 0000000..95a099e --- /dev/null +++ b/.github/scripts/activate.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -e + +F4PGA_FAM=${F4PGA_FAM:=xc7} + +case "$F4PGA_FAM" in + xc7) F4PGA_DIR_ROOT='install';; + eos-s3) F4PGA_DIR_ROOT='quicklogic-arch-defs';; +esac + +export PATH="$F4PGA_INSTALL_DIR/$F4PGA_FAM/$F4PGA_DIR_ROOT/bin:$PATH" +source "$F4PGA_INSTALL_DIR/$F4PGA_FAM/conda/etc/profile.d/conda.sh" + +conda activate $F4PGA_FAM diff --git a/.github/scripts/prepare_environment.sh b/.github/scripts/prepare_environment.sh new file mode 100755 index 0000000..1311720 --- /dev/null +++ b/.github/scripts/prepare_environment.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + + +echo '::group::Install dependencies' +sudo apt update -y +sudo apt install -y git wget xz-utils +echo '::endgroup::' + + +echo '::group::Clone f4pga-examples' +git clone --recurse-submodules https://github.com/chipsalliance/f4pga-examples +cd f4pga-examples +echo '::endgroup::' + + +F4PGA_FAM=${F4PGA_FAM:=xc7} + +echo '::group::Install Miniconda3' +wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda_installer.sh + +F4PGA_INSTALL_DIR_FAM="$F4PGA_INSTALL_DIR/$F4PGA_FAM" + +bash conda_installer.sh -u -b -p "$F4PGA_INSTALL_DIR_FAM"/conda +source "$F4PGA_INSTALL_DIR_FAM"/conda/etc/profile.d/conda.sh +echo '::endgroup::' + + +echo '::group::Create environment' +conda env create -f "$F4PGA_FAM"/environment.yml +echo '::endgroup::' + + +echo '::group::Install arch-defs' +case "$F4PGA_FAM" in + xc7) + mkdir -p "$F4PGA_INSTALL_DIR_FAM"/install + wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/535/20220128-000432/symbiflow-arch-defs-install-5fa5e715.tar.xz | tar -xJC $F4PGA_INSTALL_DIR/xc7/install + wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/535/20220128-000432/symbiflow-arch-defs-xc7a50t_test-5fa5e715.tar.xz | tar -xJC $F4PGA_INSTALL_DIR/xc7/install + ;; + eos-s3) + wget -qO- https://storage.googleapis.com/symbiflow-arch-defs-install/quicklogic-arch-defs-63c3d8f9.tar.gz | tar -xz -C $F4PGA_INSTALL_DIR_FAM + ;; +esac +echo '::endgroup::' diff --git a/.github/workflows/Automerge.yml b/.github/workflows/Automerge.yml index 28b8647..cdb61b1 100644 --- a/.github/workflows/Automerge.yml +++ b/.github/workflows/Automerge.yml @@ -12,7 +12,7 @@ jobs: Pipeline: if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} - uses: ./.github/workflows/Doc.yml + uses: ./.github/workflows/Pipeline.yml Automerge: diff --git a/.github/workflows/Doc.yml b/.github/workflows/Doc.yml deleted file mode 100644 index 9b9bddb..0000000 --- a/.github/workflows/Doc.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Docs - -on: - workflow_call: - -jobs: - - Docs: - runs-on: ubuntu-latest - name: '📓 Docs' - steps: - - - name: '🧰 Checkout' - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: 🛠️ Setup environment - run: | - sudo apt update -qq - sudo apt install -y make - make env - - - name: 📓 Build the documentation - run: | - . ./env/conda/bin/activate f4pga-docs - make html - - - name: '📤 Upload artifact: Sphinx HTML' - uses: actions/upload-artifact@v3 - with: - name: Documentation-HTML - path: _build/html - - - name: 🚀 Publish site to GitHub Pages - if: github.event_name != 'pull_request' - run: | - cd _build/html - touch .nojekyll - git init - cp ../../.git/config ./.git/config - git add . - git config --local user.email "BuildTheDocs@GitHubActions" - git config --local user.name "GitHub Actions" - git commit -a -m "update ${{ github.sha }}" - git push -u origin +HEAD:gh-pages diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml new file mode 100644 index 0000000..aa26500 --- /dev/null +++ b/.github/workflows/Pipeline.yml @@ -0,0 +1,98 @@ +name: Pipeline + +on: + workflow_call: + +jobs: + + Docs: + runs-on: ubuntu-latest + name: '📓 Docs' + steps: + + - name: '🧰 Checkout' + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: 🛠️ Setup environment + run: | + sudo apt update -qq + sudo apt install -y make + make env + + - name: 📓 Build the documentation + run: | + . ./env/conda/bin/activate f4pga-docs + make html + + - name: '📤 Upload artifact: Sphinx HTML' + uses: actions/upload-artifact@v3 + with: + name: Documentation-HTML + path: _build/html + + - name: 🚀 Publish site to GitHub Pages + if: github.event_name != 'pull_request' + run: | + cd _build/html + touch .nojekyll + git init + cp ../../.git/config ./.git/config + git add . + git config --local user.email "BuildTheDocs@GitHubActions" + git config --local user.name "GitHub Actions" + git commit -a -m "update ${{ github.sha }}" + git push -u origin +HEAD:gh-pages + + + Example: + runs-on: ubuntu-latest + name: '🐍 Example' + strategy: + fail-fast: false + matrix: + include: + - { fam: xc7, example: counter_test } + - { fam: eos-s3, example: btn_counter } + env: + F4PGA_INSTALL_DIR: /opt/f4pga + F4PGA_FAM: ${{ matrix.fam }} + + steps: + + - name: '🧰 Checkout' + uses: actions/checkout@v3 + + - name: '🔧 Prepare environment' + run: ./.github/scripts/prepare_environment.sh + + - name: '🚧 Test make example' + run: | + . ./.github/scripts/activate.sh + + export VPRPATH=$(f4pga-env bin) + + cd f4pga-examples + cd ${{ matrix.fam }} + + case '${{ matrix.fam }}' in + xc7) TARGET="arty_35" make -C counter_test;; + eos-s3) make -C btn_counter;; + esac + + - name: '📤 Upload artifact: Arty 35 bitstream' + if: matrix.fam == 'xc7' + uses: actions/upload-artifact@v3 + with: + name: arty_35-Bitstream + path: f4pga-examples/xc7/counter_test/build/arty_35/top.bit + if-no-files-found: error + + - name: '📤 Upload artifact: QuickLogic bitstream' + if: matrix.fam == 'eos-s3' + uses: actions/upload-artifact@v3 + with: + name: eos-s3-Bitstream + path: f4pga-examples/eos-s3/btn_counter/build/top.bit + if-no-files-found: error