diff --git a/.github/workflows/scraper.yml b/.github/workflows/scraper.yml new file mode 100644 index 00000000..774160b0 --- /dev/null +++ b/.github/workflows/scraper.yml @@ -0,0 +1,52 @@ +on: + push: + workflow_dispatch: + inputs: + release: + description: Version + required: false +name: Scraper +jobs: + scraper: + name: Run + runs-on: ubuntu-latest + steps: + - name: Install ssconvert + run: sudo apt-get -y --no-install-recommends install gnumeric + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + bundler-cache: true + - name: Install scraper dependencies + run: bundle install + working-directory: scraper + - name: Run scraper + run: bash bootstrap.sh + working-directory: scraper/scripts + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: release-artifact + path: | + scraper/scripts/data/* + ! scraper/scripts/data/by-bank.tar + php: + needs: scraper + name: Post-scraper tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + tools: phpunit, composer + - run: composer install --no-interaction + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: release-artifact + path: scraper/scripts/data + - run: phpunit -d memory_limit=-1 + env: + RUN_DATASET_TESTS: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..cd645a81 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +on: push +name: Tests +jobs: + node: + strategy: + matrix: + node: ["16", "14", "12"] + name: Node.js + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v2 + with: + node-version: ${{matrix.node}} + - run: npm install + - run: npm test + php: + strategy: + matrix: + # https://www.php.net/supported-versions.php + php: ["7.3", "7.4", "8.0"] + name: PHP + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{matrix.php}} + tools: phpunit, composer + - run: composer install --no-interaction + - run: phpunit -d memory_limit=-1 + ruby: + strategy: + matrix: + ruby: ["3.0", "2.6", "2.7"] + name: Ruby + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle install + - run: bundle exec rake diff --git a/.npmignore b/.npmignore index 099cabb6..67551b1f 100644 --- a/.npmignore +++ b/.npmignore @@ -35,3 +35,4 @@ src/patches/* tests/ tmp/ *.csv +.github/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eb1ee59..b2b77061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [UNRELEASED][unreleased] +## [2.0.0][2.0.0] +### Removed +- Removed support for Elixir package +### Changed +- Builds are now powered by GitHub Actions, instead of Wercker ## [1.6.1][1.6.1] ### Added @@ -210,7 +215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removes some data formats (YAML/Large JSON) for cleaner code. If you were using them, please let create an issue. -[unreleased]: https://github.com/razorpay/ifsc/compare/1.6.1...HEAD +[unreleased]: https://github.com/razorpay/ifsc/compare/2.0.0...HEAD +[2.0.0]: https://github.com/razorpay/ifsc/releases/tag/2.0.0 [1.6.1]: https://github.com/razorpay/ifsc/releases/tag/1.6.1 [1.5.13]: https://github.com/razorpay/ifsc/releases/tag/1.5.13 [1.5.12]: https://github.com/razorpay/ifsc/releases/tag/1.5.12 diff --git a/README.md b/README.md index 12aba666..66b6b036 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,15 @@ This is part of the IFSC toolset released by Razorpay. You can find more details about the entire release at [ifsc.razorpay.com](https://ifsc.razorpay.com). -[![wercker status](https://app.wercker.com/status/bc9b22047e1b8eb55ce98ba451d7b504/s/master 'wercker status')](https://app.wercker.com/project/byKey/bc9b22047e1b8eb55ce98ba451d7b504) [![](https://images.microbadger.com/badges/image/razorpay/ifsc:1.6.1.svg)](https://microbadger.com/images/razorpay/ifsc:1.6.1) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) +[![](https://images.microbadger.com/badges/image/razorpay/ifsc:1.6.1.svg)](https://microbadger.com/images/razorpay/ifsc:1.6.1) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![](https://images.microbadger.com/badges/version/razorpay/ifsc:1.6.1.svg)](https://microbadger.com/images/razorpay/ifsc:1.6.1) [![npm version](https://badge.fury.io/js/ifsc.svg)](https://badge.fury.io/js/ifsc) [![Gem Version](https://badge.fury.io/rb/ifsc.svg)](https://badge.fury.io/rb/ifsc) [![PHP version](https://badge.fury.io/ph/razorpay%2Fifsc.svg)](https://badge.fury.io/ph/razorpay%2Fifsc) [![Hex pm](http://img.shields.io/hexpm/v/ifsc.svg)](https://hex.pm/packages/ifsc) ## Dataset -If you are just looking for the dataset, go to -the [releases][releases] section and download -the latest release. +If you are just looking for the dataset, go to the [releases][releases] section and download the latest release. -The latest [`build` pipeline][buildlist] on Wercker should result in a container -with the complete dataset as well. +The latest `scraper` workflow on GitHub should publish a `release-artifact` as well. ### Source @@ -93,7 +90,6 @@ Only the latest version of each SDK is considered. | -------- | ---------- | ---------- | ----------------------- | -------------- | | PHP | ✅ | ✅ | ✅ (✅) | ✅ | | Ruby | ✅ | ✅ | ✅ (✅) | ✅ | -| Elixir | ✅ | ✅ | ✅ (❎) | ❎ | | Node.js | ✅ | ✅ | ❎ (❎) | ✅ | ## API Documentation @@ -281,60 +277,6 @@ Razorpay::IFSC::IFSC.find '...' code = Razorpay::IFSC::IFSC.new '...'; code.get ``` -### Elixir - -Documentation: [https://hexdocs.pm/ifsc](https://hexdocs.pm/ifsc) - -Online validation - -```elixir -iex> IFSC.get("KKBK0000261") -{:ok, - %Razorpay.IFSC{ - address: "JMD REGENT SQUARE,MEHRAULI GURGAON ROAD,OPPOSITE BRISTOL HOTEL,", - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - branch: "GURGAON", - city: "GURGAON", - contact: "4131000", - district: "GURGAON", - ifsc: "KKBK0000261", - rtgs: true, - state: "HARYANA" - }} - -iex> IFSC.get("foobar") -{:error, :invalid_ifsc} -``` - -Offline validation - -```elixir -iex> IFSC.validate("KKBK0000261") -{:ok, - %Razorpay.IFSC{ - address: nil, - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - branch: nil, - city: nil, - contact: nil, - district: nil, - ifsc: "KKBK0000261", - rtgs: nil, - state: nil - }} - -iex> IFSC.validate("foobar") -{:error, :invalid_format} - -iex> IFSC.validate("AAAA0000000") -{:error, :invalid_bank_code} - -iex(> IFSC.validate("HDFC0000000") -{:error, :invalid_branch_code} -``` - ### Code Notes Both the packages ship with a 300kb JSON file, that @@ -358,6 +300,5 @@ is under public domain. [combined]: https://rbidocs.rbi.org.in/rdocs/content/docs/68774.xlsx [releases]: https://github.com/razorpay/ifsc/releases -[buildlist]: https://app.wercker.com/razorpay/ifsc/runs?view=runs&q=pipeline%3Abuild [rtgs]: https://rbidocs.rbi.org.in/rdocs/RTGS/DOCs/RTGEB0815.xlsx [ach]: https://www.npci.org.in/what-we-do/nach/live-members/live-banks diff --git a/composer.json b/composer.json index 765d5a7e..33a64f51 100644 --- a/composer.json +++ b/composer.json @@ -23,31 +23,27 @@ "/node_modules/", "/src/node/", "/src/ruby/", - "/src/elixir/", "/tests/ruby/", "/tests/node/", - "/tests/elixir/", "/tests/fixture/exvcr/", "/.npmignore", "/Gemfile*", "/package.json", - "/mix.exs", - "/mix.lock", "/priv/ifsc-data/" ] }, "require": { "php": "^7.1|^8.0", "php-http/client-implementation": "^1.0", - "php-http/discovery": "^1.6", + "php-http/discovery": "^1.14", "php-http/message-factory": "^1.0", "psr/http-message": "^1.0" }, "require-dev": { - "guzzlehttp/psr7" : "^1.3", - "php-http/message" : "^1.7", - "php-http/mock-client" : "^0.3 || ^1.0", - "phpunit/phpunit" : "^6.0 || ^8.0 || ^7.0", + "guzzlehttp/psr7" : "^2.0", + "php-http/message" : "^1.11", + "php-http/mock-client" : "^1.4", + "phpunit/phpunit" : "^9.0", "symfony/yaml": "^5.0" }, "scripts": { diff --git a/mix.exs b/mix.exs deleted file mode 100644 index 45e51e1b..00000000 --- a/mix.exs +++ /dev/null @@ -1,77 +0,0 @@ -defmodule IFSC.Mixfile do - use Mix.Project - - def project do - [ - app: :ifsc, - version: "1.6.1", - elixir: "~> 1.5", - start_permanent: Mix.env == :prod, - description: description(), - package: package(), - deps: deps(), - aliases: aliases(), - source_url: "https://github.com/razorpay/ifsc", - homepage_url: "https://ifsc.razorpay.com/", - elixirc_paths: ["src/elixir"], - test_paths: ["tests/elixir"], - ] - end - - def application do - [ - extra_applications: [:logger], - ] - end - - defp description do - "A simple package by @razorpay to help you validate your IFSC codes. " - <> "IFSC codes are bank codes within India" - end - - defp package do - [ - maintainers: [ - "Nihal Gonsalves ", - "Abhay Rana ", - ], - licenses: ["MIT"], - links: %{ - "GitHub" => "https://github.com/razorpay/ifsc", - "Website" => "https://ifsc.razorpay.com/", - }, - files: files(), - ] - end - - defp files do - [ - "src/elixir/config/**", - "src/elixir/lib/**", - "src/elixir/*.md", - "tests/elixir/**", - "tests/*.json", - "priv/*", - "src/*.json", - "*.md", - "mix.exs", - ] - end - - defp deps do - [ - {:poison, "~> 4.0"}, - {:httpoison, "~> 1.2"}, - {:memoize, "~> 1.2"}, - {:exvcr, "~> 0.10", only: :test}, - {:ex_doc, ">= 0.0.0", only: :dev}, - ] - end - - defp aliases do - [ - test: ["ifsc.copy_json", "test"], - "hex.publish": ["ifsc.copy_json", "hex.publish"], - ] - end -end diff --git a/src/elixir/README.md b/src/elixir/README.md deleted file mode 100644 index 79eca94d..00000000 --- a/src/elixir/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# IFSC - -[![Hex pm](http://img.shields.io/hexpm/v/ifsc.svg?style=flat)](https://hex.pm/packages/ifsc) - -A simple package by @razorpay to help you validate your IFSC codes. - -IFSC codes are bank codes within India - -## Documentation - -[https://hexdocs.pm/ifsc](https://hexdocs.pm/ifsc) - -## Installation - -Add `ifsc` to your list of dependencies in `mix.exs`: - - -```elixir -def deps do - [ - {:ifsc, "~> 1.1.0"} - ] -end -``` - -## Development and Publishing - -Remember to run `mix ifsc.copy_json` to populate the `priv/ifsc-data` directory, -or the `Razorpay.IFSC.validate` function will not run. - -This is because the root repository generates the IFSC data in `src/`, and to -access these files when the `ifsc` package is included in another project, -they must be inside `priv/`. - -Thus `priv/ifsc-data` is gitignore'd but populated and included when publishing to Hex. -For local development, the task must be run manually. diff --git a/src/elixir/config/config.exs b/src/elixir/config/config.exs deleted file mode 100644 index d2d855e6..00000000 --- a/src/elixir/config/config.exs +++ /dev/null @@ -1 +0,0 @@ -use Mix.Config diff --git a/src/elixir/lib/mix/tasks/copy_json.ex b/src/elixir/lib/mix/tasks/copy_json.ex deleted file mode 100644 index 7df5c6a0..00000000 --- a/src/elixir/lib/mix/tasks/copy_json.ex +++ /dev/null @@ -1,11 +0,0 @@ -defmodule Mix.Tasks.Ifsc.CopyJson do - use Mix.Task - - def run(_) do - File.mkdir_p!("priv/ifsc-data") - Enum.map( - ~w(banknames.json IFSC.json sublet.json banks.json), - &(File.copy("src/" <> &1, "priv/ifsc-data/" <> &1)) - ) - end -end diff --git a/src/elixir/lib/razorpay/ifsc.ex b/src/elixir/lib/razorpay/ifsc.ex deleted file mode 100644 index d3e620c2..00000000 --- a/src/elixir/lib/razorpay/ifsc.ex +++ /dev/null @@ -1,179 +0,0 @@ -defmodule Razorpay.IFSC do - @moduledoc """ - Razorpay IFSC Validation Module - - Online validation (fetches details from ifsc.razorpay.com) - - iex> IFSC.get("KKBK0000261") - {:ok, - %Razorpay.IFSC{ - address: "JMD REGENT SQUARE,MEHRAULI GURGAON ROAD,OPPOSITE BRISTOL HOTEL,", - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - branch: "GURGAON", - city: "GURGAON", - contact: "4131000", - district: "GURGAON", - ifsc: "KKBK0000261", - rtgs: true, - state: "HARYANA" - }} - - iex> IFSC.get("foobar") - {:error, :invalid_ifsc} - - Offline validation using the dataset in the package - please keep `ifsc` up to date if using this - - (Note that only the :bank, :bank_code and :ifsc fields are populated if using offline validation) - - iex> IFSC.validate("KKBK0000261") - {:ok, - %Razorpay.IFSC{ - address: nil, - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - branch: nil, - city: nil, - contact: nil, - district: nil, - ifsc: "KKBK0000261", - rtgs: nil, - state: nil - }} - - iex> IFSC.validate("foobar") - {:error, :invalid_format} - - iex> IFSC.validate("AAAA0000000") - {:error, :invalid_bank_code} - - iex(> IFSC.validate("HDFC0000000") - {:error, :invalid_branch_code} - - """ - - alias __MODULE__.Data - - @type t :: %__MODULE__{ - ifsc: String.t, - bank: String.t | nil, - bank_code: String.t | nil, - branch: String.t | nil, - address: String.t | nil, - contact: String.t | nil, - city: String.t | nil, - district: String.t | nil, - state: String.t | nil, - rtgs: boolean | nil, - } - - @enforce_keys ~w(ifsc)a - - defstruct ~w(ifsc bank bank_code branch address contact city district state rtgs)a - - @doc """ - Fetch details about an IFSC code from the Razorpay IFSC API - """ - @spec get(ifsc :: String.t) :: {:ok, ifsc :: __MODULE__.t} | {:error, reason :: :invalid_ifsc | any} - def get(ifsc) do - with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- Data.api(ifsc), - {:ok, json} <- Poison.decode(body) - do - {:ok, %__MODULE__{ - ifsc: json["IFSC"], - bank: json["BANK"], - bank_code: json["BANKCODE"], - branch: json["BRANCH"], - address: json["ADDRESS"], - contact: json["CONTACT"], - city: json["CITY"], - district: json["DISTRICT"], - state: json["STATE"], - rtgs: json["RTGS"], - }} - else - {:ok, %HTTPoison.Response{status_code: 404}} -> - {:error, :invalid_ifsc} - {:error, %HTTPoison.Error{reason: reason}} -> - {:error, reason} - end - end - - @doc """ - Perform offline validation and return the bank and bank codes - """ - @spec validate(ifsc :: String.t) :: {:ok, ifsc :: __MODULE__.t} | - {:error, reason :: :invalid_format | :invalid_bank_code | :invalid_branch_code | any} - def validate(ifsc) do - ifsc = String.upcase(ifsc) - - with :ok <- validate_format(ifsc), - :ok <- validate_bank(ifsc), - :ok <- validate_branch(ifsc) - do - {:ok, %__MODULE__{ - ifsc: ifsc, - bank: bank_name(ifsc), - bank_code: bank_code(ifsc, :sublet), - }} - end - end - - defp validate_format(ifsc) do - if String.length(ifsc) == 11 and String.at(ifsc, 4) == "0" do - :ok - else - {:error, :invalid_format} - end - end - - defp validate_bank(ifsc) do - with {:ok, bank_data} <- Data.bank() do - if Map.has_key?(bank_data, bank_code(ifsc, :regular)) do - :ok - else - {:error, :invalid_bank_code} - end - end - end - - defp validate_branch(ifsc) do - with {:ok, ifsc_data} <- Data.ifsc() do - branches = ifsc_data[bank_code(ifsc, :regular)] - if branches && Enum.member?(branches, branch_code(ifsc)) do - :ok - else - {:error, :invalid_branch_code} - end - end - end - - defp bank_code(ifsc, :sublet) do - code = bank_code(ifsc, :regular) - - with {:ok, sublet_data} <- Data.sublet() do - sublet_data[ifsc] || code - else - _ -> code - end - end - defp bank_code(ifsc, :regular), do: String.slice(ifsc, 0..3) - - defp branch_code(ifsc) do - code = String.slice(ifsc, 5..-1) - - if code =~ ~r/^(\d)+$/ do - String.to_integer(code) - else - String.upcase(code) - end - end - - defp bank_name(ifsc) do - with {:ok, bank_data} <- Data.bank() do - bank_data[bank_code(ifsc, :sublet)] - else - _ -> nil - end - end -end diff --git a/src/elixir/lib/razorpay/ifsc/data.ex b/src/elixir/lib/razorpay/ifsc/data.ex deleted file mode 100644 index 46d5de53..00000000 --- a/src/elixir/lib/razorpay/ifsc/data.ex +++ /dev/null @@ -1,63 +0,0 @@ -defmodule Razorpay.IFSC.Data do - @moduledoc """ - Fetches data from the API or offline JSON files - """ - - use Memoize - - @api "https://ifsc.razorpay.com/" - - @doc """ - Load, parse and memoize the data for IFSC.json - """ - @spec ifsc() :: {:ok, data :: map} | {:error, reason :: any} - defmemo ifsc, do: json("IFSC") - - @doc """ - Load, parse and memoize the data for banknames.json - """ - @spec bank() :: {:ok, data :: map} | {:error, reason :: any} - defmemo bank, do: json("banknames") - - @doc """ - Load, parse and memoize the data for sublet.json - """ - @spec sublet() :: {:ok, data :: map} | {:error, reason :: any} - defmemo sublet, do: json("sublet") - - @doc """ - Fetch the JSON payload for an IFSC - """ - @spec api(ifsc :: String.t) :: {:ok, data :: map} | {:error, reason :: any} - def api(ifsc) do - case api_memoized(ifsc) do - {:ok, response} -> - {:ok, response} - {:error, reason} -> - Memoize.invalidate(__MODULE__, :api_memoized, [ifsc]) - {:error, reason} - end - end - - defmemo api_memoized(ifsc) do - ifsc - |> api_uri - |> HTTPoison.get - end - - defp json(filename) do - with {:ok, body} <- File.read(data_path(filename <> ".json")), - {:ok, json} <- Poison.decode(body) - do - {:ok, json} - end - end - - defp data_path(filename) do - :code.priv_dir(:ifsc) - |> Path.join("./ifsc-data/") - |> Path.join(filename) - end - - defp api_uri(ifsc), do: URI.merge(@api, ifsc) -end diff --git a/tests/elixir/ifsc_acceptance_test.exs b/tests/elixir/ifsc_acceptance_test.exs deleted file mode 100644 index 79db1c0d..00000000 --- a/tests/elixir/ifsc_acceptance_test.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule IFSCAcceptanceTest do - use ExUnit.Case - alias Razorpay.IFSC - - describe "acceptance" do - tests = Poison.decode!(File.read!("tests/validator_asserts.json")) - - Enum.map(tests, fn({name, cases}) -> - cases = Macro.escape(cases) - test name do - Enum.map(unquote(Macro.expand(cases, __MODULE__)), fn({ifsc, valid}) -> - if valid do - assert {:ok, %IFSC{}} = IFSC.validate(ifsc) - else - assert {:error, _reason} = IFSC.validate(ifsc) - end - end) - end - end) - end -end diff --git a/tests/elixir/ifsc_test.exs b/tests/elixir/ifsc_test.exs deleted file mode 100644 index 675daf43..00000000 --- a/tests/elixir/ifsc_test.exs +++ /dev/null @@ -1,71 +0,0 @@ -defmodule IFSCTest do - use ExUnit.Case - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney - alias Razorpay.IFSC - - @sample_data %IFSC{ - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - ifsc: "KKBK0000261", - branch: "GURGAON", - address: "JMD REGENT SQUARE,MEHRAULI GURGAON ROAD,OPPOSITE BRISTOL HOTEL,", - contact: "4131000", - city: "GURGAON", - district: "GURGAON", - state: "HARYANA", - rtgs: true, - } - - setup do - ExVCR.Config.cassette_library_dir("tests/fixture/exvcr") - end - - describe "#get" do - test "should fetch a valid code from the API correctly" do - use_cassette "valid_ifsc", match_requests_on: [:url] do - assert {:ok, @sample_data} = IFSC.get(@sample_data.ifsc) - end - end - test "should return :invalid_ifsc for an invalid code" do - use_cassette "invalid_ifsc", match_requests_on: [:url] do - assert {:error, :invalid_ifsc} = IFSC.get("foobar") - end - end - end - - describe "#validate" do - test "should validate regular numeric branch codes" do - assert {:ok, %IFSC{}} = IFSC.validate("KKBK0000261") - assert {:ok, %IFSC{}} = IFSC.validate("HDFC0002854") - assert {:ok, %IFSC{}} = IFSC.validate("KARB0000001") - assert {:ok, %IFSC{}} = IFSC.validate("DLXB0000097") - end - - test "should validate string branch codes" do - assert {:ok, %IFSC{}} = IFSC.validate("BOTM0NEEMRA") - assert {:ok, %IFSC{}} = IFSC.validate("BARB0ZOOTIN") - end - - test "should not validate invalid codes" do - assert {:error, _reason} = IFSC.validate("BOTM0XEEMRA") - assert {:error, _reason} = IFSC.validate("BOTX0000000") - assert {:error, _reason} = IFSC.validate("BOTX0000500") - assert {:error, _reason} = IFSC.validate("BOTM0000500") - assert {:error, _reason} = IFSC.validate("DLXB0000500") - end - - test "should return the correct bank name and code for regular branches" do - assert {:ok, %IFSC{ - bank: "Kotak Mahindra Bank", - bank_code: "KKBK", - }} = IFSC.validate("KKBK0000261") - end - - test "should return the correct bank name and code for sublet branches" do - assert {:ok, %IFSC{ - bank: "Darjeeling District Central Co-operative Bank", - bank_code: "DDCX", - }} = IFSC.validate("WBSC0DJCB01") - end - end -end diff --git a/tests/elixir/test_helper.exs b/tests/elixir/test_helper.exs deleted file mode 100644 index 869559e7..00000000 --- a/tests/elixir/test_helper.exs +++ /dev/null @@ -1 +0,0 @@ -ExUnit.start() diff --git a/tests/php/DatasetTest.php b/tests/php/DatasetTest.php index bdf1d989..39c17bf8 100644 --- a/tests/php/DatasetTest.php +++ b/tests/php/DatasetTest.php @@ -31,7 +31,7 @@ class DatasetTest extends TestCase public function testIFSCDotCsv() { $fileName = __DIR__ . "/../../scraper/scripts/data/IFSC.csv"; - if(file_exists($fileName) or getenv('CI')) { + if(file_exists($fileName) or getenv('RUN_DATASET_TESTS')) { $file = fopen($fileName, 'r'); $line = fgets($file); $row = str_getcsv($line); @@ -55,7 +55,7 @@ public function testIFSCDotCsv() { } } else { - $this->markTestSkipped("IFSC.csv missing. This should not be skipped in CI"); + $this->markTestSkipped("IFSC.csv missing"); } } @@ -66,23 +66,27 @@ public function testIFSCDotCsv() { public function testBankFiles() { $tarFile = __DIR__ . "/../../scraper/scripts/data/by-bank.tar"; - $dir = tempnam(sys_get_temp_dir(), '') . '.dir'; + if (file_exists($tarFile) or getenv('RUN_DATASET_TESTS')) { + $dir = tempnam(sys_get_temp_dir(), '') . '.dir'; - mkdir($dir); + mkdir($dir); - // unarchive from the tar - $phar = new PharData($tarFile); - $phar->extractTo($dir); + // unarchive from the tar + $phar = new PharData($tarFile); + $phar->extractTo($dir); - foreach(glob("$dir/by-bank/*.json") as $json) { - $data = json_decode(file_get_contents($json), true); - foreach ($data as $row) { - $ifsc = $row['IFSC']; - $fields = array_keys($row); - foreach (self::KNOWN_FIELDS as $field) { - $this->assertContains($field, $fields, "$ifsc missing $field in $json"); + foreach(glob("$dir/by-bank/*.json") as $json) { + $data = json_decode(file_get_contents($json), true); + foreach ($data as $row) { + $ifsc = $row['IFSC']; + $fields = array_keys($row); + foreach (self::KNOWN_FIELDS as $field) { + $this->assertContains($field, $fields, "$ifsc missing $field in $json"); + } } } + } else { + $this->markTestSkipped("by-bank.tar missing"); } } } diff --git a/wercker.yml b/wercker.yml deleted file mode 100644 index 42afc05c..00000000 --- a/wercker.yml +++ /dev/null @@ -1,115 +0,0 @@ -box: - id: ruby - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN -no-response-timeout: 60 -command-timeout: 60 -build: - box: - id: "ruby:latest" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - script: - name: install ssconvert - code: sudo apt-get update && sudo apt-get install --yes --no-install-recommends gnumeric - - script: - name: update bundler - code: sudo gem install bundler --version "$WERCKER_BUNDLE_INSTALL_VERSION" - - bundle-install: - cwd: scraper - - script: - name: Run bootstrap - code: bash bootstrap.sh - cwd: scraper/scripts - - script: - name: Copy artifacts - code: cp `ls | egrep -v '^by-bank.tar$'` $WERCKER_REPORT_ARTIFACTS_DIR/ - cwd: scraper/scripts/data - -# This is the ruby gem that we have -rubygem: - box: - id: "ruby" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - bundle-install - - script: - name: Run tests - cwd: src/ruby - code: bundle exec rake -# PHP package -php: - box: - id: "php:7.4" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - install-packages: - packages: git - - script: - name: install phpunit - code: |- - curl -L https://phar.phpunit.de/phpunit-7.5.2.phar -o /usr/local/bin/phpunit - chmod +x /usr/local/bin/phpunit - - script: - name: install composer - code: curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer - - script: - name: install dependencies - code: composer install --no-interaction - - script: - name: Copy Files from Build step - code: |- - cp scraper/scripts/data/*.json src/ - - script: - name: Run PHP tests - code: phpunit -d memory_limit=-1 -# Node package -node: - box: - id: "node" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - npm-install - - script: - name: run tests - code: npm test -release: - box: - id: "php:7.4" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - install-packages: - packages: git original-awk - - script: - name: Generate Release Notice - code: bash release.sh - cwd: scraper/scripts - - script: - name: Copy Release.md - code: cp scraper/scripts/release.md $WERCKER_REPORT_ARTIFACTS_DIR/ -elixir: - box: - id: "elixir" - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_ACCESS_TOKEN - steps: - - script: - name: install hex - code: mix local.hex --force - - script: - name: install rebar3 - code: mix local.rebar --force - - script: - name: get dependencies - code: mix deps.get - - script: - name: copy Files - code: mix ifsc.copy_json - - script: - name: run tests - code: mix test