Skip to content

Commit

Permalink
Implement GitHub action that automatically builds sa binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Aug 7, 2024
1 parent f15e3f8 commit 3326ac8
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda
{
"name": "Unipept Index",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/rust:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
82 changes: 82 additions & 0 deletions .github/workflows/build_index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build index binaries

on:
schedule:
# Run on the first day of every month at midnight UTC
- cron: '0 0 1 * *'
push:
branches:
- feature/build_index_action
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
# Check out the most recent version of the repository with submodules
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: recursive

# Set up Rust toolchain
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

# Compile Rust code
- name: Compile Rust code
run: cargo build --release

# Create a directory "build"
- name: Create build directory
run: mkdir -p build/input

# Download the file "suffix-array.zip" from the most recent release of "unipept-database"
- name: Download suffix-array.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest_release_url=$(curl -s https://api.github.com/repos/unipept/unipept-database/releases/latest | grep "browser_download_url.*suffix-array.zip" | cut -d '"' -f 4)
release_date=$(curl -s https://api.github.com/repos/unipept/unipept-database/releases/latest | grep '"published_at":' | cut -d '"' -f 4 | cut -d'T' -f1)
release_date_formatted=$(date -d $release_date "+%Y-%m-%d")
SP_VERSION="SP_$release_date_formatted"
echo "SP_VERSION=$SP_VERSION" >> $GITHUB_ENV
curl -L -o build/suffix-array.zip $latest_release_url
# Extract the contents of this zip into a folder "build/input"
- name: Extract zip contents
run: unzip build/suffix-array.zip -d build/input

# Make a directory with the SP_VERSION and process files
- name: Process files
run: |
mkdir -p build/$SP_VERSION
lz4 -d build/input/uniprot_entries.tsv.lz4 | cut -f2,4,7,8 > build/$SP_VERSION/proteins.tsv
lz4 -d build/input/taxons.tsv.lz4 > build/$SP_VERSION/taxons.tsv
# Step 8: Run the sa-builder command
- name: Run sa-builder
run: |
prefix="build/$SP_VERSION"
./target/release/sa-builder -d "$prefix/proteins.tsv" -t "$prefix/taxons.tsv" -o "$prefix/sa_sparse3_compressed.bin" -s 3 -a lib-div-suf-sort -c
# Zip the contents of the build/$SP_VERSION directory
- name: Zip build contents
run: |
prefix="build/$SP_VERSION"
zip -r "build/$SP_VERSION.zip" "$prefix"
# Create a GitHub release and upload the zip file
- name: Upload or Update Release
id: upload_or_update_release
uses: softprops/action-gh-release@v1
with:
files: build/$SP_VERSION.zip
tag_name: index-${{ env.SP_VERSION }}
name: Index ${{ env.SP_VERSION }}
commitish: ${{ github.sha }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions unipept-index.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

0 comments on commit 3326ac8

Please sign in to comment.