diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..769f69d9ea --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: "Build Cassandra-Stress" + +on: + workflow_dispatch: + inputs: + version: + required: false + description: 'Version of the release' + default: '' + latest: + required: false + default: false + description: 'Build latest version' + workflow_call: + inputs: + version: + required: false + description: 'Version of the release' + type: boolean + default: '' + latest: + required: false + default: false + type: boolean + description: 'Build latest version' +jobs: + build: + strategy: + matrix: + java: [ '11' ] + os: [ 'ubuntu-latest' ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: ${{ matrix.java }} + cache: 'maven' + cache-dependency-path: | + build/cassandra-stress*.pom + - name: Setup Ant + uses: cedx/setup-ant@v2 + with: + optional-tasks: true + version: latest + - name: Build with version ${{ inputs.version }} + if: ${{ inputs.version != '' }} + run: ant -Dversion=${{ inputs.version }} jar + - name: Build latest + if: ${{ inputs.version != '' }} + run: ant jar + - name: Artifacts + if: ${{ inputs.version != '' }} + run: ant -Dversion=${{ inputs.version }} artifacts + - name: Release + uses: softprops/action-gh-release@v2 + id: release + if: ${{ inputs.version != '' }} + with: + make_latest: ${{ inputs.latest }} + name: "v${{ steps.version_tag.outputs.tag }}" + tag_name: "v${{ steps.version_tag.outputs.tag }}" + generate_release_notes: true + append_body: true + prerelease: false + fail_on_unmatched_files: true + files: | + build/cassandra-stress-${{ inputs.version }}-bin.tar.gz + build/cassandra-stress-${{ inputs.version }}-bin.tar.gz.sha256 + build/cassandra-stress-${{ inputs.version }}-bin.tar.gz.sha512 + build/cassandra-stress-${{ inputs.version }}-src.tar.gz + build/cassandra-stress-${{ inputs.version }}-src.tar.gz.sha256 + build/cassandra-stress-${{ inputs.version }}-src.tar.gz.sha512 + - name: "Generate release changelog" + if: ${{ inputs.version != '' }} + uses: heinrichreimer/action-github-changelog-generator@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + author: true + releaseUrl: ${{ steps.release.outputs.url }} + issues: false + pullRequests: true + - uses: stefanzweifel/git-auto-commit-action@v5 + if: ${{ inputs.version != '' }} + with: + commit_message: "Update CHANGELOG.md" + branch: master + commit_options: '--no-verify --signoff' + file_pattern: CHANGELOG.md \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4fb43c0222..bbd2c1e775 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -47,7 +47,7 @@ on: required: false type: boolean image: - default: 'ghcr.io/codelieutenant/website' + default: 'scylladb/cassandra-stress' required: false type: string secrets: @@ -75,7 +75,6 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push API - if: ${{ inputs.dev }} uses: docker/build-push-action@v5 with: file: Dockerfile @@ -85,4 +84,6 @@ jobs: platforms: ${{ inputs.platforms }} cache-from: type=gha cache-to: type=gha,mode=max - tags: ${{ inputs.image }}:${{ inputs.version }} \ No newline at end of file + tags: ${{ inputs.image }}:latest, ${{ inputs.image }}:${{ inputs.version }} + build-args: | + VERSION=${{ inputs.version }} \ No newline at end of file diff --git a/.github/workflows/push-pull-req.yml b/.github/workflows/push-pull-req.yml new file mode 100644 index 0000000000..ebbb1f86db --- /dev/null +++ b/.github/workflows/push-pull-req.yml @@ -0,0 +1,13 @@ +name: "On Push/Pull Request" + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + uses: "./.github/workflows/build.yml" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1083681617..47f050505c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,15 +44,21 @@ jobs: branch: master commit_options: '--no-verify --signoff' file_pattern: CHANGELOG.md - docker_image: + docker: needs: ['create_release'] uses: "./.github/workflows/docker.yml" with: docker_target: production - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 version: ${{ inputs.version }} image: ${{ vars.IMAGE }} secrets: CR_PAT: ${{ secrets.CR_PAT }} REGISTRY: ${{ secrets.REGISTRY }} - REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} \ No newline at end of file + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + build: + needs: ['create_release'] + uses: "./.github/workflows/build.yml" + with: + version: ${{ inputs.version }} + latest: true diff --git a/Dockerfile b/Dockerfile index abad4ae327..5d96e4285e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apk update \ && apk add apache-ant bash \ && ant realclean \ && mkdir -p build lib \ - && ant -Dversion=${VERSION} maven-declare-dependencies artifacts \ + && ant -Dversion=$VERSION maven-declare-dependencies artifacts \ && bash ./SCYLLA-VERSION-GEN \ && cp build/SCYLLA-* build/dist/ diff --git a/test/unit/com/scylladb/tools/ColumnNamesMappingTest.java b/test/unit/com/scylladb/tools/ColumnNamesMappingTest.java deleted file mode 100644 index 1c21092587..0000000000 --- a/test/unit/com/scylladb/tools/ColumnNamesMappingTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.scylladb.tools; - -import static com.scylladb.tools.BulkLoader.findFiles; -import static com.scylladb.tools.BulkLoader.openFile; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.db.DecoratedKey; -import org.apache.cassandra.db.marshal.Int32Type; -import org.apache.cassandra.dht.Murmur3Partitioner; -import org.apache.cassandra.io.sstable.Component; -import org.apache.cassandra.io.sstable.Descriptor; -import org.apache.cassandra.io.sstable.format.SSTableReader; -import org.apache.cassandra.utils.Pair; -import org.junit.Assert; -import org.junit.Test; - -public class ColumnNamesMappingTest { - private static class MockClient implements Client { - - private final Set statements = new HashSet<>(); - - @Override - public CFMetaData getCFMetaData(String keyspace, String cfName) { - return CFMetaData.Builder.create("loader_test", "loader_test_table") - .withPartitioner(new Murmur3Partitioner()) - .addPartitionKey("new_pk1", Int32Type.instance) - .addPartitionKey("new_pk2", Int32Type.instance) - .addClusteringColumn("new_ck1", Int32Type.instance) - .addClusteringColumn("new_ck2", Int32Type.instance) - .addRegularColumn("new_val1", Int32Type.instance) - .addRegularColumn("new_val2", Int32Type.instance) - .build(); - } - - @Override - public void processStatment(DecoratedKey key, long timestamp, String what, Map objects, boolean isCounter) { - statements.add(what); - } - - public void assertStatements() { - Assert.assertTrue(statements.contains("INSERT INTO loader_test.loader_test_table (new_val1,new_pk1,new_pk2,new_ck1,new_ck2) values (?,?,?,?,?) USING TIMESTAMP ?;")); - Assert.assertTrue(statements.contains("UPDATE loader_test.loader_test_table USING TIMESTAMP ? SET new_val2 = ? WHERE new_pk1 = ? AND new_pk2 = ? AND new_ck1 = ? AND new_ck2 = ?;")); - Assert.assertTrue(statements.contains("DELETE FROM loader_test.loader_test_table USING TIMESTAMP ? WHERE new_pk1 = ? AND new_pk2 = ?;")); - } - } - - @Test - public void testColumnNamesMapping() throws Exception - { - System.setProperty("cassandra.config", "file:///" + new File("test/conf/cassandra.yaml").getAbsolutePath()); - final File dir = new File("test/data/scylla/column_names_mapping"); - final String keyspace = "loader_test"; - - final Map mapping = new HashMap<>(); - mapping.put("pk1", "new_pk1"); - mapping.put("pk2", "new_pk2"); - mapping.put("ck1", "new_ck1"); - mapping.put("ck2", "new_ck2"); - mapping.put("val1", "new_val1"); - mapping.put("val2", "new_val2"); - - MockClient client = new MockClient(); - ColumnNamesMapping columnNamesMapping = new ColumnNamesMapping(mapping); - for (Pair> p : findFiles(keyspace, dir)) { - SSTableReader r = openFile(p, columnNamesMapping.getMetadata(client.getCFMetaData(keyspace, p.left.cfname))); - if (r == null) { - continue; - } - SStableScannerSource src = new DefaultSSTableScannerSource(r, null); - SSTableToCQL.Options options = new SSTableToCQL.Options(); - options.columnNamesMapping = columnNamesMapping; - SSTableToCQL ssTableToCQL = new SSTableToCQL(src); - ssTableToCQL.run(client, options); - } - client.assertStatements(); - } - -}