Skip to content

Commit b2b31ab

Browse files
authored
Adding Github actions as an alternative to travis. (#1572)
* Adding Github actions as an alternative to travis. * This runs the same tests as travis does using github actions. * This currently doesn't upload artifacts to artifactory.
1 parent aac46ee commit b2b31ab

4 files changed

Lines changed: 146 additions & 7 deletions

File tree

.github/workflows/tests.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# This is a github actions workflow which runs htsjdk tests and spotbugs.
2+
3+
name: Build and Test
4+
on:
5+
push:
6+
branches: [master]
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
env:
13+
HTSJDK_SAMTOOLS_BIN: /usr/bin/samtools
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
java: [ 8, 11 ]
18+
experimental: [false]
19+
# include:
20+
# - java: 17
21+
# experimental: true
22+
fail-fast: false
23+
continue-on-error: ${{ matrix.experimental }}
24+
name: Java ${{ matrix.Java }} build and test
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up java ${{ matrix.Java }}
28+
uses: actions/setup-java@v2
29+
with:
30+
java-version: ${{ matrix.Java }}
31+
distribution: 'adopt'
32+
cache: gradle
33+
- name: Grant execute permission for gradlew
34+
run: chmod +x gradlew
35+
- name: Compile with Gradle
36+
run: ./gradlew compileJava
37+
- name: Install Samtools
38+
run: scripts/install-samtools.sh
39+
- name: Start the htsget server
40+
run: scripts/htsget-scripts/start-htsget-test-server.sh
41+
- name: Run tests
42+
run: ./gradlew test jacocoTestReport
43+
- name: Upload to codecov
44+
run: bash <(curl -s https://raw.githubusercontent.com/broadinstitute/codecov-bash-uploader/main/codecov-verified.bash)
45+
- name: Upload test results
46+
if: always()
47+
uses: actions/upload-artifact@v2
48+
with:
49+
name: test-results-${{ matrix.Java }}
50+
path: build/reports/tests
51+
testExternalApis:
52+
continue-on-error: true
53+
runs-on: ubuntu-latest
54+
name: Tests that require external APIs
55+
steps:
56+
- uses: actions/checkout@v2
57+
- name: Set up java 8
58+
uses: actions/setup-java@v2
59+
with:
60+
java-version: '8'
61+
distribution: 'adopt'
62+
cache: gradle
63+
- name: Grant execute permission for gradlew
64+
run: chmod +x gradlew
65+
- name: Compile with Gradle
66+
run: ./gradlew compileJava
67+
- name: Run tests
68+
run: ./gradlew testFTP jacocoTestReport
69+
- name: Upload to codecov
70+
run: bash <(curl -s https://raw.githubusercontent.com/broadinstitute/codecov-bash-uploader/main/codecov-verified.bash)
71+
- name: Upload test results
72+
if: always()
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: test-results-external-apis
76+
path: build/reports/tests
77+
testFTP:
78+
continue-on-error: true
79+
runs-on: ubuntu-latest
80+
name: FTP tests
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Set up java 8
84+
uses: actions/setup-java@v2
85+
with:
86+
java-version: '8'
87+
distribution: 'adopt'
88+
cache: gradle
89+
- name: Grant execute permission for gradlew
90+
run: chmod +x gradlew
91+
- name: Compile with Gradle
92+
run: ./gradlew compileJava
93+
- name: Run tests
94+
run: ./gradlew testFTP jacocoTestReport
95+
- name: Upload to codecov
96+
run: bash <(curl -s https://raw.githubusercontent.com/broadinstitute/codecov-bash-uploader/main/codecov-verified.bash)
97+
- name: Upload test results
98+
if: always()
99+
uses: actions/upload-artifact@v2
100+
with:
101+
name: test-results-ftp
102+
path: build/reports/tests
103+
spotBugs:
104+
runs-on: ubuntu-latest
105+
name: SpotBugs
106+
steps:
107+
- uses: actions/checkout@v2
108+
- name: Set up java 8
109+
uses: actions/setup-java@v2
110+
with:
111+
java-version: '8'
112+
distribution: 'adopt'
113+
cache: gradle
114+
- name: Grant execute permission for gradlew
115+
run: chmod +x gradlew
116+
- name: Compile with Gradle
117+
run: ./gradlew spotBugsMain spotBugsTest
118+
- name: Upload spotBugs Report
119+
if: failure()
120+
uses: actions/upload-artifact@v2
121+
with:
122+
name: spotBugs-Report
123+
path: build/reports/spotbugs
124+
125+
126+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Coverage Status](https://codecov.io/gh/samtools/htsjdk/branch/master/graph/badge.svg)](https://codecov.io/gh/samtools/htsjdk)
2-
[![Build Status](https://travis-ci.org/samtools/htsjdk.svg?branch=master)](https://travis-ci.org/samtools/htsjdk)
2+
[![Build and Test](https://github.com/samtools/htsjdk/actions/workflows/tests.yml/badge.svg?branch=master&event=push)](https://github.com/samtools/htsjdk/actions/workflows/tests.yml)
33
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.samtools/htsjdk/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.samtools%22%20AND%20a%3A%22htsjdk%22)
44
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samtools/htsjdk)
55
[![Language](http://img.shields.io/badge/language-java-brightgreen.svg)](https://www.java.com/)
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
#!/bin/sh
22

33
set -e
4+
set -v
45

56
DOCKER_NAME='ga4gh/htsget-refserver'
67
SERVER_VERSION='1.4.1'
78
DOCKER_COORDINATE=${DOCKER_NAME}:${SERVER_VERSION}
89

9-
WORKING_DIR=/home/travis/build/samtools/htsjdk
10+
CONTAINER_NAME="htsget-test-server"
11+
1012
docker pull ${DOCKER_COORDINATE}
11-
docker container run -d --name htsget-server -p 3000:3000 --env HTSGET_PORT=3000 --env HTSGET_HOST=http://127.0.0.1:3000 \
12-
-v $WORKING_DIR/src/test/resources/htsjdk/samtools/BAMFileIndexTest/:/data \
13-
-v $WORKING_DIR/scripts/htsget-scripts:/data/scripts \
13+
14+
#Remove the container if it already exists
15+
docker rm -f ${CONTAINER_NAME} || true
16+
17+
#Run the container set port mapping and mount in the data
18+
docker container run -d --name ${CONTAINER_NAME} -p 3000:3000 --env HTSGET_PORT=3000 --env HTSGET_HOST=http://127.0.0.1:3000 \
19+
-v ${PWD}/src/test/resources/htsjdk/samtools/BAMFileIndexTest/:/data \
20+
-v ${PWD}/scripts/htsget-scripts:/data/scripts \
1421
${DOCKER_COORDINATE} \
1522
./htsget-refserver -config /data/scripts/htsget_config.json
23+
24+
#give it a second(s) to start
25+
sleep 2
26+
27+
#List containers
1628
docker container ls -a
1729

18-
curl http://localhost:3000
30+
#Check that we can connect
31+
curl http://localhost:3000/reads/service-info

src/test/java/htsjdk/tribble/IntervalList/IntervalListCodecTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testTribbleDecode(final File file) throws IOException {
9292
@Test(dataProvider = "TribbleDecodeData")
9393
public void testTribbleDecodeCompressed(final File file) throws IOException {
9494
// compress 'file' to bgzf
95-
File tmpGz = File.createTempFile("htsjdk.", FileExtensions.COMPRESSED_INTERVAL_LIST, IOUtil.getDefaultTmpDir());
95+
File tmpGz = File.createTempFile("htsjdk.", FileExtensions.COMPRESSED_INTERVAL_LIST);
9696
try(BlockCompressedOutputStream bgz = new BlockCompressedOutputStream(tmpGz);
9797
FileInputStream fis = new FileInputStream(file)) {
9898
IOUtil.copyStream(fis,bgz);

0 commit comments

Comments
 (0)